Browse Source

undo changes to extractCode, using grunt task instead

main
Connor McSheffrey 11 years ago
parent
commit
89384f4071
  1. 29
      extractCode.js

29
extractCode.js

@ -16,24 +16,21 @@ function main(dest, filenames) {
if (!dest) { if (!dest) {
throw new Error('no dest provided'); throw new Error('no dest provided');
} }
console.log(filenames);
filenames.map(function (filename) { filenames.map(function (filename) {
var content = fs.readFileSync(filename).toString('utf8'); var content = fs.readFileSync(filename).toString('utf8');
var codeSamples = content.match(CODE_SAMPLE); var codeSamples = content.match(CODE_SAMPLE);
codeSamples.map(function (codeSample) { codeSamples.map(function (codeSample) {
// Do a little jank preprocessing // Do a little jank preprocessing
codeSample = codeSample.replace('<!--', '//').replace(' -->', ''); codeSample = codeSample.replace('<!--', '//').replace(' -->', '');
var extracted = codeSample.match(PARTS); var extracted = codeSample.match(PARTS);
if (!extracted) { if (!extracted) {
throw new Error('Code sample did not match correct format in ' + filename + ': ' + truncate(codeSample)); throw new Error('Code sample did not match correct format in ' + filename + ': ' + truncate(codeSample));
} }
var filename = extracted[1]; var filename = extracted[1];
var content = extracted[2].replace(/\*\*/g, ''); var content = extracted[2].replace(/\*\*/g, '');
fs.writeFileSync(argv.dest + '/' + filename, content); fs.writeFileSync(argv.dest + '/' + filename, content);
}); });
}); });
} }

Loading…
Cancel
Save