From 177c97f4d917ffc4e54bf3c3317e18b406bf2823 Mon Sep 17 00:00:00 2001 From: MatAtBread Date: Sat, 15 Oct 2016 14:16:19 +0100 Subject: [PATCH] Fix issue when handling multiple files on the command line, and "use" option is missing --- nodent.js | 27 +++++++++++++-------------- package.json | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/nodent.js b/nodent.js index 51b8d4d..b3f8597 100755 --- a/nodent.js +++ b/nodent.js @@ -98,8 +98,8 @@ var useDirective = /^\s*['"]use\s+nodent-?([a-zA-Z0-9]*)?(\s*.*)?['"]\s*;/ var runtimes = require('./lib/runtime') ; var $asyncbind = runtimes.$asyncbind ; var $asyncspawn = runtimes.$asyncspawn ; -var Thenable = $asyncbind.Thenable ; - +var Thenable = $asyncbind.Thenable ; + function noLogger(){} function isDirective(node){ @@ -166,7 +166,7 @@ function parseCompilerOptions(code,log,filename) { if (parseOpts.generators || parseOpts.engine) parseOpts.promises = true ; if (parseOpts.promises) - parseOpts.es7 = true ; + parseOpts.es7 = true ; return parseOpts ; } return null ; // No valid nodent options @@ -658,7 +658,7 @@ function initialize(initOpts){ } } } else if (filename.match(/node_modules\/nodent\/.*\.js$/)) { - // Things inside nodent always use the standard loader + // Things inside nodent always use the standard loader return stdJSLoader(mod,filename) ; } else { // The the appropriate loader for this file @@ -797,38 +797,37 @@ function runFromCLI(){ try { var pr ; var parseOpts ; - + // Input options if (cli.fromast) { content = JSON.parse(content) ; pr = { origCode:"", filename:filename, ast: content } ; parseOpts = parseCompilerOptions(content,nodent.log) ; if (!parseOpts) { - cli.use = cli.use ? '"use nodent-'+cli.use+'";' : '"use nodent";' ; - parseOpts = parseCompilerOptions(cli.use,nodent.log) ; - console.warn("/* "+filename+": No 'use nodent*' directive, assumed "+cli.use+" */") ; + var directive = cli.use ? '"use nodent-'+cli.use+'";' : '"use nodent";' ; + parseOpts = parseCompilerOptions(directive,nodent.log) ; + console.warn("/* "+filename+": No 'use nodent*' directive, assumed "+directive+" */") ; } } else { parseOpts = parseCompilerOptions(cli.use?'"use nodent-'+cli.use+'";':content,nodent.log) ; if (!parseOpts) { - cli.use = '"use nodent";' ; - parseOpts = parseCompilerOptions(cli.use,nodent.log) ; + parseOpts = parseCompilerOptions('"use nodent";',nodent.log) ; if (!cli.dest) - console.warn("/* "+filename+": 'use nodent*' directive missing/ignored, assumed "+cli.use+" */") ; + console.warn("/* "+filename+": 'use nodent*' directive missing/ignored, assumed 'use nodent;' */") ; } pr = nodent.parse(content,filename,parseOpts); } - + // Processing options if (!cli.parseast && !cli.pretty) nodent.asynchronize(pr,undefined,parseOpts,nodent.log) ; - + // Output options nodent.prettyPrint(pr,parseOpts) ; if (cli.out || cli.pretty || cli.dest) { if (cli.dest && !name) throw new Error("Can't write unknown file to "+cli.dest) ; - + var output = "" ; if (cli.runtime) { output += ("Function.prototype.$asyncbind = "+Function.prototype.$asyncbind.toString()+";\n") ; diff --git a/package.json b/package.json index bfd5d1b..eabce04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodent", - "version": "3.0.2", + "version": "3.0.3", "description": "NoDent - Asynchronous Javascript language extensions", "main": "nodent.js", "scripts": {