Comparing version 0.6.16 to 0.6.17
@@ -8,2 +8,6 @@ var chalk = require( 'chalk' ); | ||
MISSING_OUTPUT_OPTION: function () { | ||
console.error( chalk.red( 'You must specify an --output (-o) directory option when converting a directory of files' ) ); | ||
}, | ||
NO_INPUT_DETECTED: function () { | ||
@@ -25,6 +29,6 @@ console.error( chalk.red( 'No input detected! Try using the --input (-i) option' ) ); | ||
console.error( chalk.red( err.message || err ) ); | ||
if ( err.stack ) { | ||
console.error( chalk.grey( err.stack ) ); | ||
} | ||
} | ||
} | ||
@@ -35,2 +39,2 @@ | ||
process.exit( 1 ); | ||
}; | ||
}; |
@@ -35,2 +35,2 @@ Esperanto version <%= version %> | ||
For more information visit https://github.com/Rich-Harris/esperanto/wiki | ||
For more information visit https://github.com/Rich-Harris/esperanto/wiki |
@@ -88,5 +88,32 @@ var path = require( 'path' ), | ||
if ( options.input ) { | ||
return sander.readFile( options.input ) | ||
.then( String ) | ||
.then( run ); | ||
return sander.stat( options.input ).then( function ( stats ) { | ||
if ( stats.isDirectory() ) { | ||
if ( !options.output ) { | ||
handleError({ code: 'MISSING_OUTPUT_OPTION' }); | ||
} | ||
// transpile all the things | ||
return sander.lsr( options.input ).then( function ( files ) { | ||
var promises = files.map( function ( file ) { | ||
var input = path.join( options.input, file ); | ||
var output = path.join( options.output, file ); | ||
var fileOptions = assign( {}, options, { | ||
input: input, | ||
output: output, | ||
sourceMapSource: input, | ||
sourceMapFile: output | ||
}); | ||
return convert( fileOptions, method ); | ||
}); | ||
return Promise.all( promises ); | ||
}); | ||
} | ||
return sander.readFile( options.input ) | ||
.then( String ) | ||
.then( run ); | ||
}); | ||
} else { | ||
@@ -145,2 +172,18 @@ return readFromStdin().then( run ); | ||
}); | ||
} | ||
} | ||
function assign ( target ) { | ||
var sources = [].slice.call( arguments, 1 ); | ||
sources.forEach( function ( source ) { | ||
var prop; | ||
for ( prop in source ) { | ||
if ( source.hasOwnProperty( prop ) ) { | ||
target[ prop ] = source[ prop ]; | ||
} | ||
} | ||
}); | ||
return target; | ||
} |
# changelog | ||
## 0.6.17 | ||
* Sourcemap mappings are set explicitly - rather than mapping every single character, the locations from the acorn AST are used. As well as smaller sourcemaps, this results in modest performance improvements internally, and large performance improvements for external tools that work with the sourcemap | ||
## 0.6.16 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "esperanto", | ||
"description": "An easier way to convert ES6 modules to AMD and CommonJS", | ||
"version": "0.6.16", | ||
"version": "0.6.17", | ||
"author": "Rich Harris", | ||
@@ -12,3 +12,3 @@ "repository": "https://github.com/esperantojs/esperanto", | ||
"estraverse": "^1.9.0", | ||
"magic-string": "^0.4.4", | ||
"magic-string": "^0.4.5", | ||
"minimist": "^1.1.0", | ||
@@ -15,0 +15,0 @@ "sander": "^0.2.1" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
159912
4464
Updatedmagic-string@^0.4.5