From 51e742d9c88f54d3f440cf7978db8e3faca3e1d2 Mon Sep 17 00:00:00 2001 From: atomiks Date: Wed, 27 Dec 2017 19:37:02 +1100 Subject: [PATCH] Fix linting script --- scripts/lint-script.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/lint-script.js b/scripts/lint-script.js index 61e394e03..08b8228a4 100644 --- a/scripts/lint-script.js +++ b/scripts/lint-script.js @@ -29,14 +29,15 @@ try { while(jobCounter >= 20){ setTimeout(()=>{},5000); } - fs.writeFileSync(`${snippet}.temp.js`,`${originalCode}`); + const tempSnippet = snippet.replace('.md', ''); + fs.writeFileSync(`${tempSnippet}.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) => { + cp.exec(`semistandard "${tempSnippet}.temp.js" --fix`,{},(error, stdOut, stdErr) => { jobCounter += 1; - let lintedCode = fs.readFileSync(`${snippet}.temp.js`,'utf8'); + let lintedCode = fs.readFileSync(`${tempSnippet}.temp.js`,'utf8'); fs.writeFile(path.join(snippetsPath,snippet), `${snippetData.slice(0, snippetData.indexOf('```js')+5)+lintedCode+'```\n'}`); - fs.unlink(`${snippet}.temp.js`); + fs.unlink(`${tempSnippet}.temp.js`); // Log a success message console.log(`${chalk.green('SUCCESS!')} Linted snippet: ${snippet}`); // Log the time taken for the file