diff --git a/_js/examples/.eslintrc b/_js/examples/.eslintrc new file mode 100644 index 00000000..225d7850 --- /dev/null +++ b/_js/examples/.eslintrc @@ -0,0 +1,3 @@ +rules: + block-scoped-var: false + no-undef: false \ No newline at end of file diff --git a/extractCode.js b/extractCode.js index 1425065a..867118eb 100644 --- a/extractCode.js +++ b/extractCode.js @@ -1,3 +1,5 @@ +'use strict'; + var argv = require('optimist').argv; var fs = require('fs'); @@ -5,9 +7,9 @@ var CODE_SAMPLE = /```[\S]+\s*[\s\S]*?```/g; var PARTS = /```[\S]+\s*\/\/\s+(.+?)\n([\s\S]*?)```/; function truncate(s, n) { - n = n || 256 + n = n || 256; if (s.length < n) { - return s; + return s; } return s.substring(0, n) + '...'; } @@ -27,9 +29,9 @@ function main(dest, filenames) { if (!extracted) { throw new Error('Code sample did not match correct format in ' + filename + ': ' + truncate(codeSample)); } - var filename = extracted[1]; - var content = extracted[2].replace(/\*\*/g, ''); - fs.writeFileSync(argv.dest + '/' + filename, content); + var codeSampleFilename = extracted[1]; + var codeSampleContent = extracted[2].replace(/\*\*/g, ''); + fs.writeFileSync(argv.dest + '/' + codeSampleFilename, codeSampleContent); }); }); }