Skip to content

Commit

Permalink
support for sending snippets into a temp folder (microsoft#3959)
Browse files Browse the repository at this point in the history
* support for sending snippets into a temp folder

* duh

* moving file to temp
  • Loading branch information
pelikhan authored May 16, 2018
1 parent 699a35d commit 8eb8d53
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,7 @@ webapp/public/closure-library
node_modules
*.sw?
built
temp
packaged
gh-pages
/typings
Expand Down
16 changes: 9 additions & 7 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 75,16 @@ task('default', ['updatestrings', 'built/pxt.js', 'built/pxt.d.ts', 'built/pxtru
task('test', ['default', 'testfmt', 'testerr', 'testdecompiler', 'testlang', 'karma'])

task('clean', function () {
expand(["built"]).forEach(f => {
try {
fs.unlinkSync(f)
} catch (e) {
console.log("cannot unlink:", f, e.message)
}
["built", "temp"].forEach(d => {
expand([d]).forEach(f => {
try {
fs.unlinkSync(f)
} catch (e) {
console.log("cannot unlink:", f, e.message)
}
})
jake.rmRf(d)
})
jake.rmRf("built")
})

setupTest('testdecompiler', 'decompile-test', 'decompilerunner.js')
Expand Down
6 changes: 4 additions & 2 deletions cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3903,6 3903,7 @@ function internalStaticPkgAsync(builtPackaged: string, label: string, minify: bo
export function cleanAsync(parsed: commandParser.ParsedCommand) {
pxt.log('cleaning built folders')
return rimrafAsync("built", {})
.then(() => rimrafAsync("temp", {}))
.then(() => rimrafAsync("libs/**/built", {}))
.then(() => rimrafAsync("projects/**/built", {}))
.then(() => { });
Expand Down Expand Up @@ -4515,7 4516,7 @@ function internalCheckDocsAsync(compileSnippets?: boolean, re?: string): Promise

function addSnippet(snippet: CodeSnippet, entryPath: string, snipIndex: number) {
snippets.push(snippet);
const dir = path.join("built/snippets", snippet.type);
const dir = path.join("temp/snippets", snippet.type);
const fn = `${dir}/${entryPath.replace(/^\//, '').replace(/\//g, '-').replace(/\.\w $/, '')}-${snipIndex}.${snippet.ext}`;
nodeutil.mkdirP(dir);
fs.writeFileSync(fn, snippet.code);
Expand Down Expand Up @@ -4606,7 4607,8 @@ function internalCheckDocsAsync(compileSnippets?: boolean, re?: string): Promise
getCodeSnippets(entrypath, md).forEach((snippet, snipIndex) => addSnippet(snippet, entrypath, snipIndex));
}

fs.writeFileSync("built/noSUMMARY.md", noTOCs.sort().map(p => `${Array(p.split(/[\/\\]/g).length - 1).join(' ')}* [${pxt.Util.capitalize(p.split(/[\/\\]/g).reverse()[0].split('-').join(' '))}](${p})`).join('\n'), { encoding: "utf8" });
nodeutil.mkdirP("temp");
fs.writeFileSync("temp/noSUMMARY.md", noTOCs.sort().map(p => `${Array(p.split(/[\/\\]/g).length - 1).join(' ')}* [${pxt.Util.capitalize(p.split(/[\/\\]/g).reverse()[0].split('-').join(' '))}](${p})`).join('\n'), { encoding: "utf8" });

let p = Promise.resolve();
// test targetconfig
Expand Down

0 comments on commit 8eb8d53

Please sign in to comment.