From 8caafdf1d95805719bf76def22a2350e3028b749 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 23 Dec 2017 11:52:07 +0200 Subject: [PATCH] Updated linter, linted scripts --- scripts/lint-script.js | 6 ++++++ snippets/call.md | 2 +- snippets/collectInto.md | 2 +- snippets/flip.md | 2 +- snippets/spreadOver.md | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/lint-script.js b/scripts/lint-script.js index 4aaa7c240..61e394e03 100644 --- a/scripts/lint-script.js +++ b/scripts/lint-script.js @@ -10,6 +10,7 @@ var snippetsPath = './snippets'; // Read files, lint each one individually and update try { let snippetFilenames = fs.readdirSync(snippetsPath); + let jobCounter = 0; snippetFilenames.sort((a, b) => { a = a.toLowerCase(); b = b.toLowerCase(); @@ -25,10 +26,14 @@ try { // Synchronously read data from the snippet, get the code, write it to a temporary file let snippetData = fs.readFileSync(path.join(snippetsPath,snippet),'utf8'); let originalCode = snippetData.slice(snippetData.indexOf('```js')+5,snippetData.lastIndexOf('```')); + while(jobCounter >= 20){ + setTimeout(()=>{},5000); + } fs.writeFileSync(`${snippet}.temp.js`,`${originalCode}`); // Run semistandard asynchronously (only way this manages to run), get linted code // and write back to the original snippet file. Remove temporary file cp.exec(`semistandard "${snippet}.temp.js" --fix`,{},(error, stdOut, stdErr) => { + jobCounter += 1; let lintedCode = fs.readFileSync(`${snippet}.temp.js`,'utf8'); fs.writeFile(path.join(snippetsPath,snippet), `${snippetData.slice(0, snippetData.indexOf('```js')+5)+lintedCode+'```\n'}`); fs.unlink(`${snippet}.temp.js`); @@ -36,6 +41,7 @@ try { console.log(`${chalk.green('SUCCESS!')} Linted snippet: ${snippet}`); // Log the time taken for the file console.timeEnd(`Linter (${snippet})`); + jobCounter -= 1; }); } } diff --git a/snippets/call.md b/snippets/call.md index bbc60ecaa..a7aec4808 100644 --- a/snippets/call.md +++ b/snippets/call.md @@ -11,4 +11,4 @@ Promise.resolve( [ 1, 2, 3 ] ).then( call('map', x => 2 * x ) ).then( console.lo const map = call.bind(null, 'map') Promise.resolve( [ 1, 2, 3 ] ).then( map( x => 2 * x ) ).then( console.log ) //[ 2, 4, 6 ] */ -``` +``` diff --git a/snippets/collectInto.md b/snippets/collectInto.md index eb0e4df6c..c9a823d3d 100644 --- a/snippets/collectInto.md +++ b/snippets/collectInto.md @@ -13,4 +13,4 @@ let p2 = Promise.resolve(2) let p3 = new Promise((resolve) => setTimeout(resolve,2000,3)) Pall(p1, p2, p3).then(console.log) */ -``` +``` diff --git a/snippets/flip.md b/snippets/flip.md index 91eae77a0..ecad926a7 100644 --- a/snippets/flip.md +++ b/snippets/flip.md @@ -15,4 +15,4 @@ mergePerson(b) // == b b = {} Object.assign(b, a) // == b */ -``` +``` diff --git a/snippets/spreadOver.md b/snippets/spreadOver.md index 94527aa19..aff6281a6 100644 --- a/snippets/spreadOver.md +++ b/snippets/spreadOver.md @@ -11,4 +11,4 @@ const arrayMax = spreadOver(Math.max) arrayMax([1,2,3]) // -> 3 arrayMax([1,2,4]) // -> 4 */ -``` +```