Template Upload
This commit is contained in:
28
node_modules/buble/bin/buble
generated
vendored
Normal file
28
node_modules/buble/bin/buble
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env node
|
||||
var minimist = require( 'minimist' );
|
||||
|
||||
var command = minimist( process.argv.slice( 2 ), {
|
||||
alias: {
|
||||
// Short options
|
||||
h: 'help',
|
||||
i: 'input',
|
||||
m: 'sourcemap',
|
||||
o: 'output',
|
||||
v: 'version',
|
||||
t: 'target',
|
||||
y: 'yes',
|
||||
n: 'no'
|
||||
}
|
||||
});
|
||||
|
||||
if ( command.help || ( process.argv.length <= 2 && process.stdin.isTTY ) ) {
|
||||
require( './showHelp' )();
|
||||
}
|
||||
|
||||
else if ( command.version ) {
|
||||
console.log( 'Bublé version ' + require( '../package.json' ).version );
|
||||
}
|
||||
|
||||
else {
|
||||
require( './runBuble' )( command );
|
||||
}
|
46
node_modules/buble/bin/handleError.js
generated
vendored
Normal file
46
node_modules/buble/bin/handleError.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
var chalk = require( 'chalk' );
|
||||
|
||||
var handlers = {
|
||||
MISSING_INPUT_OPTION: function () {
|
||||
console.error( chalk.red( 'You must specify an --input (-i) option' ) );
|
||||
},
|
||||
|
||||
MISSING_OUTPUT_DIR: function () {
|
||||
console.error( chalk.red( 'You must specify an --output (-o) option when compiling a directory of files' ) );
|
||||
},
|
||||
|
||||
MISSING_OUTPUT_FILE: function () {
|
||||
console.error( chalk.red( 'You must specify an --output (-o) option when creating a file with a sourcemap' ) );
|
||||
},
|
||||
|
||||
ONE_AT_A_TIME: function ( err ) {
|
||||
console.error( chalk.red( 'Bublé can only compile one file/directory at a time' ) );
|
||||
},
|
||||
|
||||
DUPLICATE_IMPORT_OPTIONS: function ( err ) {
|
||||
console.error( chalk.red( 'use --input, or pass input path as argument – not both' ) );
|
||||
},
|
||||
|
||||
BAD_TARGET: function ( err ) {
|
||||
console.error( chalk.red( 'illegal --target option' ) );
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function handleError ( err ) {
|
||||
var handler;
|
||||
|
||||
if ( handler = handlers[ err && err.code ] ) {
|
||||
handler( err );
|
||||
} else {
|
||||
if ( err.snippet ) console.error( chalk.red( '---\n' + err.snippet ) );
|
||||
console.error( chalk.red( err.message || err ) );
|
||||
|
||||
if ( err.stack ) {
|
||||
console.error( chalk.grey( err.stack ) );
|
||||
}
|
||||
}
|
||||
|
||||
console.error( 'Type ' + chalk.cyan( 'buble --help' ) + ' for help, or visit https://buble.surge.sh/guide/' );
|
||||
|
||||
process.exit( 1 );
|
||||
};
|
42
node_modules/buble/bin/help.md
generated
vendored
Normal file
42
node_modules/buble/bin/help.md
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
Bublé version <%= version %>
|
||||
=====================================
|
||||
|
||||
Usage: buble [options] <entry file>
|
||||
|
||||
Basic options:
|
||||
|
||||
-v, --version Show version number
|
||||
-h, --help Show this help message
|
||||
-i, --input Input (alternative to <entry file>)
|
||||
-o, --output <output> Output (if absent, prints to stdout)
|
||||
-m, --sourcemap Generate sourcemap (`-m inline` for inline map)
|
||||
-t, --target Select compilation targets
|
||||
-y, --yes Transforms to always apply (overrides --target)
|
||||
-n, --no Transforms to always skip (overrides --target)
|
||||
--jsx Custom JSX pragma
|
||||
|
||||
Examples:
|
||||
|
||||
# Compile input.js to output.js
|
||||
buble input.js > output.js
|
||||
|
||||
# Compile input.js to output.js, write sourcemap to output.js.map
|
||||
buble input.js -o output.js -m
|
||||
|
||||
# Compile input.js to output.js with inline sourcemap
|
||||
buble input.js -o output.js -m inline
|
||||
|
||||
# Only use transforms necessary for output.js to run in FF43 and Node 5
|
||||
buble input.js -o output.js -t firefox:43,node:5
|
||||
|
||||
# As above, but use arrow function and destructuring transforms
|
||||
buble input.js -o output.js -t firefox:43,node:5 -y arrow,destructuring
|
||||
|
||||
# Compile all the files in src/ to dest/
|
||||
buble src -o dest
|
||||
|
||||
Notes:
|
||||
|
||||
* When piping to stdout, only inline sourcemaps are permitted
|
||||
|
||||
For more information visit http://buble.surge.sh/guide
|
136
node_modules/buble/bin/runBuble.js
generated
vendored
Normal file
136
node_modules/buble/bin/runBuble.js
generated
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
var fs = require( 'fs' );
|
||||
var path = require( 'path' );
|
||||
var buble = require( '../dist/buble.deps.js' );
|
||||
var handleError = require( './handleError.js' );
|
||||
var EOL = require('os').EOL;
|
||||
|
||||
function compile ( from, to, command, options ) {
|
||||
try {
|
||||
var stats = fs.statSync( from );
|
||||
if ( stats.isDirectory() ) {
|
||||
compileDir( from, to, command, options );
|
||||
} else {
|
||||
compileFile( from, to, command, options );
|
||||
}
|
||||
} catch ( err ) {
|
||||
handleError( err );
|
||||
}
|
||||
}
|
||||
|
||||
function compileDir ( from, to, command, options ) {
|
||||
if ( !command.output ) handleError({ code: 'MISSING_OUTPUT_DIR' });
|
||||
|
||||
try {
|
||||
fs.mkdirSync( to )
|
||||
} catch ( e ) {
|
||||
if ( e.code !== 'EEXIST' ) throw e
|
||||
}
|
||||
|
||||
fs.readdirSync( from ).forEach( function ( file ) {
|
||||
compile( path.resolve( from, file ), path.resolve( to, file ), command, options );
|
||||
});
|
||||
}
|
||||
|
||||
function compileFile ( from, to, command, options ) {
|
||||
var ext = path.extname( from );
|
||||
|
||||
if ( ext !== '.js' && ext !== '.jsm' && ext !== '.es6' ) return;
|
||||
|
||||
if ( to ) to = to.slice( 0, -ext.length ) + '.js';
|
||||
|
||||
var source = fs.readFileSync( from, 'utf-8' );
|
||||
var result = buble.transform( source, {
|
||||
target: options.target,
|
||||
transforms: options.transforms,
|
||||
source: from,
|
||||
file: to,
|
||||
jsx: options.jsx
|
||||
});
|
||||
|
||||
write( result, to, command );
|
||||
}
|
||||
|
||||
function write ( result, to, command ) {
|
||||
if ( command.sourcemap === 'inline' ) {
|
||||
result.code += EOL + '//# sourceMappingURL=' + result.map.toUrl();
|
||||
} else if ( command.sourcemap ) {
|
||||
if ( !to ) {
|
||||
handleError({ code: 'MISSING_OUTPUT_FILE' });
|
||||
}
|
||||
|
||||
result.code += EOL + '//# sourceMappingURL=' + path.basename( to ) + '.map';
|
||||
fs.writeFileSync( to + '.map', result.map.toString() );
|
||||
}
|
||||
|
||||
if ( to ) {
|
||||
fs.writeFileSync( to, result.code );
|
||||
} else {
|
||||
console.log( result.code ); // eslint-disable-line no-console
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function ( command ) {
|
||||
if ( command._.length > 1 ) {
|
||||
handleError({ code: 'ONE_AT_A_TIME' });
|
||||
}
|
||||
|
||||
if ( command._.length === 1 ) {
|
||||
if ( command.input ) {
|
||||
handleError({ code: 'DUPLICATE_IMPORT_OPTIONS' });
|
||||
}
|
||||
|
||||
command.input = command._[0];
|
||||
}
|
||||
|
||||
var options = {
|
||||
target: {},
|
||||
transforms: {},
|
||||
jsx: command.jsx
|
||||
};
|
||||
|
||||
if ( command.target ) {
|
||||
if ( !/^(?:(\w+):([\d\.]+),)*(\w+):([\d\.]+)$/.test( command.target ) ) {
|
||||
handleError({ code: 'BAD_TARGET' });
|
||||
}
|
||||
|
||||
command.target.split( ',' )
|
||||
.map( function ( target ) {
|
||||
return target.split( ':' );
|
||||
})
|
||||
.forEach( function ( pair ) {
|
||||
options.target[ pair[0] ] = pair[1];
|
||||
});
|
||||
}
|
||||
|
||||
if ( command.yes ) {
|
||||
command.yes.split( ',' ).forEach( function ( transform ) {
|
||||
options.transforms[ transform ] = true;
|
||||
});
|
||||
}
|
||||
|
||||
if ( command.no ) {
|
||||
command.no.split( ',' ).forEach( function ( transform ) {
|
||||
options.transforms[ transform ] = false;
|
||||
});
|
||||
}
|
||||
|
||||
if ( command.input ) {
|
||||
compile( command.input, command.output, command, options );
|
||||
}
|
||||
|
||||
else {
|
||||
process.stdin.resume();
|
||||
process.stdin.setEncoding( 'utf8' );
|
||||
|
||||
var source = '';
|
||||
|
||||
process.stdin.on( 'data', function ( chunk ) {
|
||||
source += chunk;
|
||||
});
|
||||
|
||||
process.stdin.on( 'end', function () {
|
||||
var result = buble.transform( source, options );
|
||||
write( result, null, command );
|
||||
});
|
||||
}
|
||||
};
|
13
node_modules/buble/bin/showHelp.js
generated
vendored
Normal file
13
node_modules/buble/bin/showHelp.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
var fs = require( 'fs' );
|
||||
var path = require( 'path' );
|
||||
|
||||
module.exports = function () {
|
||||
fs.readFile( path.join( __dirname, 'help.md' ), function ( err, result ) {
|
||||
var help;
|
||||
|
||||
if ( err ) throw err;
|
||||
|
||||
help = result.toString().replace( '<%= version %>', require( '../package.json' ).version );
|
||||
console.log( '\n' + help + '\n' );
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user