Skip to content

Commit

Permalink
Fix issue when handling multiple files on the command line, and "use"…
Browse files Browse the repository at this point in the history
… option is missing
  • Loading branch information
MatAtBread committed Oct 15, 2016
1 parent 9f67204 commit 177c97f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions nodent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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") ;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodent",
"version": "3.0.2",
"version": "3.0.3",
"description": "NoDent - Asynchronous Javascript language extensions",
"main": "nodent.js",
"scripts": {
Expand Down

0 comments on commit 177c97f

Please sign in to comment.