initial commit
This commit is contained in:
142
node_modules/babel/bin/_babel-node
generated
vendored
Normal file
142
node_modules/babel/bin/_babel-node
generated
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var pathIsAbsolute = require("path-is-absolute");
|
||||
var commander = require("commander");
|
||||
var Module = require("module");
|
||||
var babel = require("babel-core");
|
||||
var inspect = require("util").inspect;
|
||||
var path = require("path");
|
||||
var repl = require("repl");
|
||||
var util = require("babel-core").util;
|
||||
var vm = require("vm");
|
||||
var _ = require("lodash");
|
||||
|
||||
var program = new commander.Command("babel-node");
|
||||
|
||||
program.option("-e, --eval [script]", "Evaluate script");
|
||||
program.option("-p, --print [code]", "Evaluate script and print result");
|
||||
program.option("-i, --ignore [regex]", "Ignore all files that match this regex when using the require hook");
|
||||
program.option("-x, --extensions [extensions]", "List of extensions to hook into [.es6,.js,.es,.jsx]");
|
||||
program.option("-r, --stage [stage]", "Enable support for specific ECMAScript stages");
|
||||
program.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
|
||||
program.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list);
|
||||
program.option("-o, --optional [optional]", "List of optional transformers to enable", util.list);
|
||||
|
||||
var pkg = require("../package.json");
|
||||
program.version(pkg.version);
|
||||
program.usage("[options] [ -e script | script.js ] [arguments]");
|
||||
program.parse(process.argv);
|
||||
|
||||
//
|
||||
|
||||
babel.register({
|
||||
extensions: program.extensions,
|
||||
blacklist: program.blacklist,
|
||||
whitelist: program.whitelist,
|
||||
optional: program.optional,
|
||||
ignore: program.ignore,
|
||||
stage: program.stage,
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
var _eval = function (code, filename) {
|
||||
if (!code) return undefined;
|
||||
|
||||
code = babel.transform(code, {
|
||||
filename: filename,
|
||||
blacklist: program.blacklist,
|
||||
whitelist: program.whitelist,
|
||||
optional: program.optional,
|
||||
stage: program.stage
|
||||
}).code;
|
||||
|
||||
return vm.runInThisContext(code, {
|
||||
filename: filename
|
||||
});
|
||||
};
|
||||
|
||||
if (program.eval || program.print) {
|
||||
var code = program.eval;
|
||||
if (!code || code === true) code = program.print;
|
||||
|
||||
global.__filename = "[eval]";
|
||||
global.__dirname = process.cwd();
|
||||
|
||||
var module = new Module(global.__filename);
|
||||
module.filename = global.__filename;
|
||||
module.paths = Module._nodeModulePaths(global.__dirname);
|
||||
|
||||
global.exports = module.exports;
|
||||
global.module = module;
|
||||
global.require = module.require.bind(module);
|
||||
|
||||
var result = _eval(code, global.__filename);
|
||||
if (program.print) {
|
||||
var output = _.isString(result) ? result : inspect(result);
|
||||
process.stdout.write(output + "\n");
|
||||
}
|
||||
} else {
|
||||
if (program.args.length) {
|
||||
// slice all arguments up to the first filename since they're babel args that we handle
|
||||
var args = process.argv.slice(2);
|
||||
|
||||
var i = 0;
|
||||
var ignoreNext = false;
|
||||
_.each(args, function (arg, i2) {
|
||||
if (ignoreNext) {
|
||||
ignoreNext = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg[0] === "-") {
|
||||
var parsedArg = program[arg.slice(2)];
|
||||
if (parsedArg && parsedArg !== true) {
|
||||
ignoreNext = true;
|
||||
}
|
||||
} else {
|
||||
i = i2;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
args = args.slice(i);
|
||||
|
||||
// make the filename absolute
|
||||
var filename = args[0];
|
||||
if (!pathIsAbsolute(filename)) args[0] = path.join(process.cwd(), filename);
|
||||
|
||||
// add back on node and concat the sliced args
|
||||
process.argv = ["node"].concat(args);
|
||||
|
||||
Module.runMain();
|
||||
} else {
|
||||
replStart();
|
||||
}
|
||||
}
|
||||
|
||||
function replStart() {
|
||||
repl.start({
|
||||
prompt: "> ",
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
eval: replEval,
|
||||
useGlobal: true
|
||||
});
|
||||
}
|
||||
|
||||
function replEval(code, context, filename, callback) {
|
||||
var err;
|
||||
var result;
|
||||
|
||||
try {
|
||||
if (code[0] === "(" && code[code.length - 1] === ")") {
|
||||
code = code.slice(1, -1); // remove "(" and ")"
|
||||
}
|
||||
|
||||
result = _eval(code, filename);
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
|
||||
callback(err, result);
|
||||
}
|
13
node_modules/babel/bin/babel-external-helpers
generated
vendored
Executable file
13
node_modules/babel/bin/babel-external-helpers
generated
vendored
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var commander = require("commander");
|
||||
var util = require("babel-core").util;
|
||||
var runtime = require("babel-core").buildExternalHelpers;
|
||||
|
||||
commander.option("-l, --whitelist [whitelist]", "Whitelist of helpers to ONLY include", util.list);
|
||||
commander.option("-t, --output-type [type]", "Type of output (global|umd|var)", "global");
|
||||
|
||||
commander.usage("[options]");
|
||||
commander.parse(process.argv);
|
||||
|
||||
console.log(runtime(commander.whitelist, commander.outputType));
|
448
node_modules/babel/bin/babel-node
generated
vendored
Executable file
448
node_modules/babel/bin/babel-node
generated
vendored
Executable file
@ -0,0 +1,448 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* This tiny wrapper file checks for known node flags and appends them
|
||||
* when found, before invoking the "real" _babel-node(1) executable.
|
||||
*/
|
||||
|
||||
var args = [__dirname + "/_babel-node"];
|
||||
|
||||
var babelArgs = process.argv.slice(2);
|
||||
var userArgs;
|
||||
|
||||
// separate node arguments from script arguments
|
||||
var argSeparator = babelArgs.indexOf("--");
|
||||
if (argSeparator > -1) {
|
||||
userArgs = babelArgs.slice(argSeparator); // including the --
|
||||
babelArgs = babelArgs.slice(0, argSeparator);
|
||||
}
|
||||
|
||||
babelArgs.forEach(function(arg){
|
||||
var flag = arg.split("=")[0];
|
||||
|
||||
switch (flag) {
|
||||
case "-d":
|
||||
args.unshift("--debug");
|
||||
break;
|
||||
|
||||
case "debug":
|
||||
case "--debug":
|
||||
case "--debug-brk":
|
||||
args.unshift(arg);
|
||||
break;
|
||||
|
||||
case "-gc":
|
||||
case "--expose-gc":
|
||||
args.unshift("--expose-gc");
|
||||
break;
|
||||
|
||||
case "--use_strict":
|
||||
case "--es_staging":
|
||||
case "--harmony":
|
||||
case "--harmony_shipping":
|
||||
case "--harmony_modules":
|
||||
case "--harmony_arrays":
|
||||
case "--harmony_array_includes":
|
||||
case "--harmony_regexps":
|
||||
case "--harmony_arrow_functions":
|
||||
case "--harmony_proxies":
|
||||
case "--harmony_sloppy":
|
||||
case "--harmony_unicode":
|
||||
case "--harmony_tostring":
|
||||
case "--harmony_numeric_literals":
|
||||
case "--harmony_strings":
|
||||
case "--harmony_scoping":
|
||||
case "--harmony_classes":
|
||||
case "--harmony_object_literals":
|
||||
case "--harmony_templates":
|
||||
case "--compiled_keyed_generic_loads":
|
||||
case "--pretenuring_call_new":
|
||||
case "--allocation_site_pretenuring":
|
||||
case "--trace_pretenuring":
|
||||
case "--trace_pretenuring_statistics":
|
||||
case "--track_fields":
|
||||
case "--track_double_fields":
|
||||
case "--track_heap_object_fields":
|
||||
case "--track_computed_fields":
|
||||
case "--track_field_types":
|
||||
case "--smi_binop":
|
||||
case "--vector_ics":
|
||||
case "--optimize_for_size":
|
||||
case "--unbox_double_arrays":
|
||||
case "--string_slices":
|
||||
case "--crankshaft":
|
||||
case "--hydrogen_filter":
|
||||
case "--use_gvn":
|
||||
case "--gvn_iterations":
|
||||
case "--use_canonicalizing":
|
||||
case "--use_inlining":
|
||||
case "--use_escape_analysis":
|
||||
case "--use_allocation_folding":
|
||||
case "--use_local_allocation_folding":
|
||||
case "--use_write_barrier_elimination":
|
||||
case "--max_inlining_levels":
|
||||
case "--max_inlined_source_size":
|
||||
case "--max_inlined_nodes":
|
||||
case "--max_inlined_nodes_cumulative":
|
||||
case "--loop_invariant_code_motion":
|
||||
case "--fast_math":
|
||||
case "--collect_megamorphic_maps_from_stub_cache":
|
||||
case "--hydrogen_stats":
|
||||
case "--trace_check_elimination":
|
||||
case "--trace_hydrogen":
|
||||
case "--trace_hydrogen_filter":
|
||||
case "--trace_hydrogen_stubs":
|
||||
case "--trace_hydrogen_file":
|
||||
case "--trace_phase":
|
||||
case "--trace_inlining":
|
||||
case "--trace_load_elimination":
|
||||
case "--trace_store_elimination":
|
||||
case "--trace_alloc":
|
||||
case "--trace_all_uses":
|
||||
case "--trace_range":
|
||||
case "--trace_gvn":
|
||||
case "--trace_representation":
|
||||
case "--trace_removable_simulates":
|
||||
case "--trace_escape_analysis":
|
||||
case "--trace_allocation_folding":
|
||||
case "--trace_track_allocation_sites":
|
||||
case "--trace_migration":
|
||||
case "--trace_generalization":
|
||||
case "--stress_pointer_maps":
|
||||
case "--stress_environments":
|
||||
case "--deopt_every_n_times":
|
||||
case "--deopt_every_n_garbage_collections":
|
||||
case "--print_deopt_stress":
|
||||
case "--trap_on_deopt":
|
||||
case "--trap_on_stub_deopt":
|
||||
case "--deoptimize_uncommon_cases":
|
||||
case "--polymorphic_inlining":
|
||||
case "--use_osr":
|
||||
case "--array_bounds_checks_elimination":
|
||||
case "--trace_bce":
|
||||
case "--array_bounds_checks_hoisting":
|
||||
case "--array_index_dehoisting":
|
||||
case "--analyze_environment_liveness":
|
||||
case "--load_elimination":
|
||||
case "--check_elimination":
|
||||
case "--store_elimination":
|
||||
case "--dead_code_elimination":
|
||||
case "--fold_constants":
|
||||
case "--trace_dead_code_elimination":
|
||||
case "--unreachable_code_elimination":
|
||||
case "--trace_osr":
|
||||
case "--stress_runs":
|
||||
case "--lookup_sample_by_shared":
|
||||
case "--cache_optimized_code":
|
||||
case "--flush_optimized_code_cache":
|
||||
case "--inline_construct":
|
||||
case "--inline_arguments":
|
||||
case "--inline_accessors":
|
||||
case "--escape_analysis_iterations":
|
||||
case "--optimize_for_in":
|
||||
case "--concurrent_recompilation":
|
||||
case "--job_based_recompilation":
|
||||
case "--trace_concurrent_recompilation":
|
||||
case "--concurrent_recompilation_queue_length":
|
||||
case "--concurrent_recompilation_delay":
|
||||
case "--block_concurrent_recompilation":
|
||||
case "--concurrent_osr":
|
||||
case "--omit_map_checks_for_leaf_maps":
|
||||
case "--turbo_filter":
|
||||
case "--trace_turbo":
|
||||
case "--trace_turbo_graph":
|
||||
case "--trace_turbo_cfg_file":
|
||||
case "--trace_turbo_types":
|
||||
case "--trace_turbo_scheduler":
|
||||
case "--trace_turbo_reduction":
|
||||
case "--trace_turbo_jt":
|
||||
case "--turbo_asm":
|
||||
case "--turbo_verify":
|
||||
case "--turbo_stats":
|
||||
case "--turbo_types":
|
||||
case "--turbo_source_positions":
|
||||
case "--context_specialization":
|
||||
case "--turbo_deoptimization":
|
||||
case "--turbo_inlining":
|
||||
case "--turbo_inlining_intrinsics":
|
||||
case "--trace_turbo_inlining":
|
||||
case "--loop_assignment_analysis":
|
||||
case "--turbo_profiling":
|
||||
case "--turbo_reuse_spill_slots":
|
||||
case "--turbo_delay_ssa_decon":
|
||||
case "--turbo_move_optimization":
|
||||
case "--turbo_jt":
|
||||
case "--typed_array_max_size_in_heap":
|
||||
case "--frame_count":
|
||||
case "--interrupt_budget":
|
||||
case "--type_info_threshold":
|
||||
case "--generic_ic_threshold":
|
||||
case "--self_opt_count":
|
||||
case "--trace_opt_verbose":
|
||||
case "--debug_code":
|
||||
case "--code_comments":
|
||||
case "--enable_sse3":
|
||||
case "--enable_sse4_1":
|
||||
case "--enable_sahf":
|
||||
case "--enable_avx":
|
||||
case "--enable_fma3":
|
||||
case "--enable_vfp3":
|
||||
case "--enable_armv7":
|
||||
case "--enable_armv8":
|
||||
case "--enable_neon":
|
||||
case "--enable_sudiv":
|
||||
case "--enable_mls":
|
||||
case "--enable_movw_movt":
|
||||
case "--enable_unaligned_accesses":
|
||||
case "--enable_32dregs":
|
||||
case "--enable_vldr_imm":
|
||||
case "--force_long_branches":
|
||||
case "--expose_natives_as":
|
||||
case "--expose_debug_as":
|
||||
case "--expose_free_buffer":
|
||||
case "--expose_gc":
|
||||
case "--expose_gc_as":
|
||||
case "--expose_externalize_string":
|
||||
case "--expose_trigger_failure":
|
||||
case "--stack_trace_limit":
|
||||
case "--builtins_in_stack_traces":
|
||||
case "--disable_native_files":
|
||||
case "--inline_new":
|
||||
case "--trace_codegen":
|
||||
case "--trace":
|
||||
case "--mask_constants_with_cookie":
|
||||
case "--lazy":
|
||||
case "--trace_opt":
|
||||
case "--trace_opt_stats":
|
||||
case "--opt":
|
||||
case "--always_opt":
|
||||
case "--always_osr":
|
||||
case "--prepare_always_opt":
|
||||
case "--trace_deopt":
|
||||
case "--trace_stub_failures":
|
||||
case "--serialize_toplevel":
|
||||
case "--serialize_inner":
|
||||
case "--trace_serializer":
|
||||
case "--min_preparse_length":
|
||||
case "--max_opt_count":
|
||||
case "--compilation_cache":
|
||||
case "--cache_prototype_transitions":
|
||||
case "--cpu_profiler_sampling_interval":
|
||||
case "--trace_debug_json":
|
||||
case "--trace_js_array_abuse":
|
||||
case "--trace_external_array_abuse":
|
||||
case "--trace_array_abuse":
|
||||
case "--enable_liveedit":
|
||||
case "--hard_abort":
|
||||
case "--stack_size":
|
||||
case "--max_stack_trace_source_length":
|
||||
case "--always_inline_smi_code":
|
||||
case "--min_semi_space_size":
|
||||
case "--target_semi_space_size":
|
||||
case "--max_semi_space_size":
|
||||
case "--semi_space_growth_factor":
|
||||
case "--experimental_new_space_growth_heuristic":
|
||||
case "--max_old_space_size":
|
||||
case "--initial_old_space_size":
|
||||
case "--max_executable_size":
|
||||
case "--gc_global":
|
||||
case "--gc_interval":
|
||||
case "--trace_gc":
|
||||
case "--trace_gc_nvp":
|
||||
case "--trace_gc_ignore_scavenger":
|
||||
case "--trace_idle_notification":
|
||||
case "--trace_idle_notification_verbose":
|
||||
case "--print_cumulative_gc_stat":
|
||||
case "--print_max_heap_committed":
|
||||
case "--trace_gc_verbose":
|
||||
case "--trace_fragmentation":
|
||||
case "--collect_maps":
|
||||
case "--weak_embedded_maps_in_optimized_code":
|
||||
case "--weak_embedded_objects_in_optimized_code":
|
||||
case "--flush_code":
|
||||
case "--flush_code_incrementally":
|
||||
case "--trace_code_flushing":
|
||||
case "--age_code":
|
||||
case "--incremental_marking":
|
||||
case "--incremental_marking_steps":
|
||||
case "--concurrent_sweeping":
|
||||
case "--trace_incremental_marking":
|
||||
case "--track_gc_object_stats":
|
||||
case "--heap_profiler_trace_objects":
|
||||
case "--use_idle_notification":
|
||||
case "--use_ic":
|
||||
case "--trace_ic":
|
||||
case "--native_code_counters":
|
||||
case "--always_compact":
|
||||
case "--never_compact":
|
||||
case "--compact_code_space":
|
||||
case "--incremental_code_compaction":
|
||||
case "--cleanup_code_caches_at_gc":
|
||||
case "--use_marking_progress_bar":
|
||||
case "--zap_code_space":
|
||||
case "--random_seed":
|
||||
case "--trace_weak_arrays":
|
||||
case "--track_prototype_users":
|
||||
case "--use_verbose_printer":
|
||||
case "--allow_natives_syntax":
|
||||
case "--trace_parse":
|
||||
case "--trace_sim":
|
||||
case "--debug_sim":
|
||||
case "--check_icache":
|
||||
case "--stop_sim_at":
|
||||
case "--sim_stack_alignment":
|
||||
case "--sim_stack_size":
|
||||
case "--log_regs_modified":
|
||||
case "--log_colour":
|
||||
case "--ignore_asm_unimplemented_break":
|
||||
case "--trace_sim_messages":
|
||||
case "--stack_trace_on_illegal":
|
||||
case "--abort_on_uncaught_exception":
|
||||
case "--randomize_hashes":
|
||||
case "--hash_seed":
|
||||
case "--profile_deserialization":
|
||||
case "--regexp_optimization":
|
||||
case "--testing_bool_flag":
|
||||
case "--testing_maybe_bool_flag":
|
||||
case "--testing_int_flag":
|
||||
case "--testing_float_flag":
|
||||
case "--testing_string_flag":
|
||||
case "--testing_prng_seed":
|
||||
case "--testing_serialization_file":
|
||||
case "--startup_blob":
|
||||
case "--profile_hydrogen_code_stub_compilation":
|
||||
case "--predictable":
|
||||
case "--help":
|
||||
case "--dump_counters":
|
||||
case "--debugger":
|
||||
case "--map_counters":
|
||||
case "--js_arguments":
|
||||
case "--gdbjit":
|
||||
case "--gdbjit_full":
|
||||
case "--gdbjit_dump":
|
||||
case "--gdbjit_dump_filter":
|
||||
case "--force_marking_deque_overflows":
|
||||
case "--stress_compaction":
|
||||
case "--log":
|
||||
case "--log_all":
|
||||
case "--log_api":
|
||||
case "--log_code":
|
||||
case "--log_gc":
|
||||
case "--log_handles":
|
||||
case "--log_snapshot_positions":
|
||||
case "--log_suspect":
|
||||
case "--prof":
|
||||
case "--prof_browser_mode":
|
||||
case "--log_regexp":
|
||||
case "--logfile":
|
||||
case "--logfile_per_isolate":
|
||||
case "--ll_prof":
|
||||
case "--perf_basic_prof":
|
||||
case "--perf_jit_prof":
|
||||
case "--gc_fake_mmap":
|
||||
case "--log_internal_timer_events":
|
||||
case "--log_timer_events":
|
||||
case "--log_instruction_stats":
|
||||
case "--log_instruction_file":
|
||||
case "--log_instruction_period":
|
||||
case "--redirect_code_traces":
|
||||
case "--redirect_code_traces_to":
|
||||
case "--hydrogen_track_positions":
|
||||
case "--trace_elements_transitions":
|
||||
case "--trace_creation_allocation_sites":
|
||||
case "--print_code_stubs":
|
||||
case "--test_secondary_stub_cache":
|
||||
case "--test_primary_stub_cache":
|
||||
case "--print_code":
|
||||
case "--print_opt_code":
|
||||
case "--print_unopt_code":
|
||||
case "--print_code_verbose":
|
||||
case "--print_builtin_code":
|
||||
case "--sodium":
|
||||
case "--print_all_code":
|
||||
case "--es5_readonly":
|
||||
case "--es52_globals":
|
||||
case "--harmony_typeof":
|
||||
case "--harmony_collections":
|
||||
case "--packed_arrays":
|
||||
case "--smi_only_arrays":
|
||||
case "--clever_optimizations":
|
||||
case "--use_range":
|
||||
case "--eliminate_dead_phis":
|
||||
case "--optimize_closures":
|
||||
case "--loop_weight":
|
||||
case "--opt_safe_uint32_operations":
|
||||
case "--parallel_recompilation":
|
||||
case "--trace_parallel_recompilation":
|
||||
case "--parallel_recompilation_queue_length":
|
||||
case "--experimental_profiler":
|
||||
case "--watch_ic_patching":
|
||||
case "--self_optimization":
|
||||
case "--direct_self_opt":
|
||||
case "--retry_self_opt":
|
||||
case "--count_based_interrupts":
|
||||
case "--interrupt_at_exit":
|
||||
case "--weighted_back_edges":
|
||||
case "--debug_code (generate extra code":
|
||||
case "--enable_sse2":
|
||||
case "--enable_cmov":
|
||||
case "--enable_rdtsc":
|
||||
case "--enable_vfp2":
|
||||
case "--enable_fpu":
|
||||
case "--stack_trace_on_abort":
|
||||
case "--always_full_compiler":
|
||||
case "--debugger_auto_break":
|
||||
case "--break_on_abort":
|
||||
case "--max_new_space_size":
|
||||
case "--trace_external_memory":
|
||||
case "--lazy_sweeping":
|
||||
case "--trace_exception":
|
||||
case "--preallocate_message_memory":
|
||||
case "--preemption":
|
||||
case "--extra_code":
|
||||
case "--remote_debugger":
|
||||
case "--debugger_agent":
|
||||
case "--debugger_port":
|
||||
case "--debug_compile_events":
|
||||
case "--debug_script_collected_events":
|
||||
case "--gdbjit":
|
||||
case "--log_runtime":
|
||||
case "--prof_auto":
|
||||
case "--prof_lazy":
|
||||
case "--sliding_state_window":
|
||||
args.unshift(arg);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (arg.indexOf("--trace") === 0) {
|
||||
args.unshift(arg);
|
||||
} else {
|
||||
args.push(arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// append arguments passed after --
|
||||
if (argSeparator > -1) {
|
||||
args = args.concat(userArgs);
|
||||
}
|
||||
|
||||
try {
|
||||
var kexec = require("kexec");
|
||||
kexec(process.argv[0], args);
|
||||
} catch (err) {
|
||||
if (err.code !== "MODULE_NOT_FOUND") throw err;
|
||||
|
||||
var child_process = require("child_process");
|
||||
var proc = child_process.spawn(process.argv[0], args, { stdio: "inherit" });
|
||||
proc.on("exit", function (code, signal) {
|
||||
process.on("exit", function () {
|
||||
if (signal) {
|
||||
process.kill(process.pid, signal);
|
||||
} else {
|
||||
process.exit(code);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
78
node_modules/babel/bin/babel/dir.js
generated
vendored
Normal file
78
node_modules/babel/bin/babel/dir.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
var outputFileSync = require("output-file-sync");
|
||||
var chokidar = require("chokidar");
|
||||
var path = require("path");
|
||||
var util = require("./util");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
module.exports = function (commander, filenames, opts) {
|
||||
var write = function (src, relative) {
|
||||
// remove extension and then append back on .js
|
||||
relative = relative.replace(/\.(\w*?)$/, "") + ".js";
|
||||
|
||||
var dest = path.join(commander.outDir, relative);
|
||||
|
||||
var data = util.compile(src, {
|
||||
sourceFileName: path.relative(dest + "/..", src)
|
||||
});
|
||||
|
||||
if (commander.sourceMaps && commander.sourceMaps !== "inline") {
|
||||
var mapLoc = dest + ".map";
|
||||
data.code = util.addSourceMappingUrl(data.code, mapLoc);
|
||||
outputFileSync(mapLoc, JSON.stringify(data.map));
|
||||
}
|
||||
|
||||
outputFileSync(dest, data.code);
|
||||
|
||||
console.log(src + " -> " + dest);
|
||||
};
|
||||
|
||||
var handleFile = function (src, filename) {
|
||||
if (util.shouldIgnore(src)) return;
|
||||
|
||||
if (util.canCompile(filename)) {
|
||||
write(src, filename);
|
||||
} else if (commander.copyFiles) {
|
||||
outputFileSync(path.join(commander.outDir, filename), fs.readFileSync(src));
|
||||
}
|
||||
};
|
||||
|
||||
var handle = function (filename) {
|
||||
if (!fs.existsSync(filename)) return;
|
||||
|
||||
var stat = fs.statSync(filename);
|
||||
|
||||
if (stat.isDirectory(filename)) {
|
||||
var dirname = filename;
|
||||
|
||||
_.each(util.readdir(dirname), function (filename) {
|
||||
var src = path.join(dirname, filename);
|
||||
handleFile(src, filename);
|
||||
});
|
||||
} else {
|
||||
write(filename, filename);
|
||||
}
|
||||
};
|
||||
|
||||
_.each(filenames, handle);
|
||||
|
||||
if (commander.watch) {
|
||||
_.each(filenames, function (dirname) {
|
||||
var watcher = chokidar.watch(dirname, {
|
||||
persistent: true,
|
||||
ignoreInitial: true
|
||||
});
|
||||
|
||||
_.each(["add", "change"], function (type) {
|
||||
watcher.on(type, function (filename) {
|
||||
var relative = path.relative(dirname, filename) || filename;
|
||||
try {
|
||||
handleFile(filename, relative);
|
||||
} catch (err) {
|
||||
console.error(err.stack);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
143
node_modules/babel/bin/babel/file.js
generated
vendored
Normal file
143
node_modules/babel/bin/babel/file.js
generated
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
var convertSourceMap = require("convert-source-map");
|
||||
var sourceMap = require("source-map");
|
||||
var chokidar = require("chokidar");
|
||||
var path = require("path");
|
||||
var util = require("./util");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
module.exports = function (commander, filenames, opts) {
|
||||
if (commander.sourceMaps === "inline") {
|
||||
opts.sourceMaps = true;
|
||||
}
|
||||
|
||||
var results = [];
|
||||
|
||||
var buildResult = function () {
|
||||
var map = new sourceMap.SourceMapGenerator({
|
||||
file: commander.outFile || "stdout"
|
||||
});
|
||||
|
||||
var code = "";
|
||||
var offset = 0;
|
||||
|
||||
_.each(results, function (result) {
|
||||
var filename = result.filename;
|
||||
code += result.code + "\n";
|
||||
|
||||
if (result.map) {
|
||||
var consumer = new sourceMap.SourceMapConsumer(result.map);
|
||||
|
||||
map._sources.add(filename);
|
||||
map.setSourceContent(filename, result.actual);
|
||||
|
||||
consumer.eachMapping(function (mapping) {
|
||||
map._mappings.add({
|
||||
generatedLine: mapping.generatedLine + offset,
|
||||
generatedColumn: mapping.generatedColumn,
|
||||
originalLine: mapping.originalLine,
|
||||
originalColumn: mapping.originalColumn,
|
||||
source: filename
|
||||
});
|
||||
});
|
||||
|
||||
offset = code.split("\n").length;
|
||||
}
|
||||
});
|
||||
|
||||
if (commander.sourceMaps === "inline" || (!commander.outFile && commander.sourceMaps)) {
|
||||
code += "\n" + convertSourceMap.fromObject(map).toComment();
|
||||
}
|
||||
|
||||
return {
|
||||
map: map,
|
||||
code: code
|
||||
};
|
||||
};
|
||||
|
||||
var output = function () {
|
||||
var result = buildResult();
|
||||
|
||||
if (commander.outFile) {
|
||||
if (commander.sourceMaps && commander.sourceMaps !== "inline") {
|
||||
var mapLoc = commander.outFile + ".map";
|
||||
result.code = util.addSourceMappingUrl(result.code, mapLoc);
|
||||
fs.writeFileSync(mapLoc, JSON.stringify(result.map));
|
||||
}
|
||||
|
||||
fs.writeFileSync(commander.outFile, result.code);
|
||||
} else {
|
||||
process.stdout.write(result.code + "\n");
|
||||
}
|
||||
};
|
||||
|
||||
var stdin = function () {
|
||||
var code = "";
|
||||
|
||||
process.stdin.setEncoding("utf8");
|
||||
|
||||
process.stdin.on("readable", function () {
|
||||
var chunk = process.stdin.read();
|
||||
if (chunk !== null) code += chunk;
|
||||
});
|
||||
|
||||
process.stdin.on("end", function () {
|
||||
results.push(util.transform(commander.filename, code));
|
||||
output();
|
||||
});
|
||||
};
|
||||
|
||||
var walk = function () {
|
||||
var _filenames = [];
|
||||
results = [];
|
||||
|
||||
_.each(filenames, function (filename) {
|
||||
if (!fs.existsSync(filename)) return;
|
||||
|
||||
var stat = fs.statSync(filename);
|
||||
if (stat.isDirectory()) {
|
||||
var dirname = filename;
|
||||
|
||||
_.each(util.readdirFilter(filename), function (filename) {
|
||||
_filenames.push(path.join(dirname, filename));
|
||||
});
|
||||
} else {
|
||||
_filenames.push(filename);
|
||||
}
|
||||
});
|
||||
|
||||
_.each(_filenames, function (filename) {
|
||||
if (util.shouldIgnore(filename)) return;
|
||||
|
||||
results.push(util.compile(filename));
|
||||
});
|
||||
|
||||
output();
|
||||
};
|
||||
|
||||
var files = function () {
|
||||
walk();
|
||||
|
||||
if (commander.watch) {
|
||||
chokidar.watch(filenames, {
|
||||
persistent: true,
|
||||
ignoreInitial: true
|
||||
}).on("all", function (type, filename) {
|
||||
if (type === "add" || type === "change") {
|
||||
console.log(type, filename);
|
||||
try {
|
||||
walk();
|
||||
} catch (err) {
|
||||
console.error(err.stack);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (filenames.length) {
|
||||
files();
|
||||
} else {
|
||||
stdin();
|
||||
}
|
||||
};
|
122
node_modules/babel/bin/babel/index.js
generated
vendored
Executable file
122
node_modules/babel/bin/babel/index.js
generated
vendored
Executable file
@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var commander = require("commander");
|
||||
var transform = require("babel-core").transform;
|
||||
var kebabCase = require("lodash/string/kebabCase");
|
||||
var options = require("babel-core").options;
|
||||
var util = require("babel-core").util;
|
||||
var each = require("lodash/collection/each");
|
||||
var keys = require("lodash/object/keys");
|
||||
var fs = require("fs");
|
||||
|
||||
each(options, function (option, key) {
|
||||
if (option.hidden) return;
|
||||
|
||||
var arg = kebabCase(key);
|
||||
|
||||
if (option.type !== "boolean") {
|
||||
arg += " [" + (option.type || "string") + "]";
|
||||
}
|
||||
|
||||
if (option.type === "boolean" && option.default === true) {
|
||||
arg = "no-" + arg;
|
||||
}
|
||||
|
||||
arg = "--" + arg;
|
||||
|
||||
if (option.shorthand) {
|
||||
arg = "-" + option.shorthand + ", " + arg;
|
||||
}
|
||||
|
||||
var desc = [];
|
||||
if (option.deprecated) desc.push("[DEPRECATED] " + option.deprecated);
|
||||
if (option.description) desc.push(option.description);
|
||||
|
||||
commander.option(arg, desc.join(" "));
|
||||
})
|
||||
|
||||
commander.option("-w, --watch", "Recompile files on changes");
|
||||
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
|
||||
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
|
||||
commander.option("-D, --copy-files", "When compiling a directory copy over non-compilable files");
|
||||
|
||||
commander.on("--help", function () {
|
||||
var outKeys = function (title, obj) {
|
||||
console.log(" " + title + ":");
|
||||
console.log();
|
||||
|
||||
each(keys(obj).sort(), function (key) {
|
||||
if (key[0] === "_") return;
|
||||
|
||||
if (obj[key].optional) key = "[" + key + "]";
|
||||
|
||||
console.log(" - " + key);
|
||||
});
|
||||
|
||||
console.log();
|
||||
};
|
||||
|
||||
outKeys("Transformers", transform.transformers);
|
||||
outKeys("Module formatters", transform.moduleFormatters);
|
||||
});
|
||||
|
||||
var pkg = require("../../package.json");
|
||||
commander.version(pkg.version);
|
||||
commander.usage("[options] <files ...>");
|
||||
commander.parse(process.argv);
|
||||
|
||||
//
|
||||
|
||||
var errors = [];
|
||||
|
||||
var filenames = commander.args;
|
||||
|
||||
each(filenames, function (filename) {
|
||||
if (!fs.existsSync(filename)) {
|
||||
errors.push(filename + " doesn't exist");
|
||||
}
|
||||
});
|
||||
|
||||
if (commander.outDir && !filenames.length) {
|
||||
errors.push("filenames required for --out-dir");
|
||||
}
|
||||
|
||||
if (commander.outFile && commander.outDir) {
|
||||
errors.push("cannot have --out-file and --out-dir");
|
||||
}
|
||||
|
||||
if (commander.watch) {
|
||||
if (!commander.outFile && !commander.outDir) {
|
||||
errors.push("--watch requires --out-file or --out-dir");
|
||||
}
|
||||
|
||||
if (!filenames.length) {
|
||||
errors.push("--watch requires filenames");
|
||||
}
|
||||
}
|
||||
|
||||
if (errors.length) {
|
||||
console.error(errors.join(". "));
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
var opts = exports.opts = {};
|
||||
|
||||
each(options, function (opt, key) {
|
||||
opts[key] = commander[key];
|
||||
});
|
||||
|
||||
opts.ignore = util.arrayify(opts.ignore, util.regexify);
|
||||
opts.only = util.arrayify(opts.only, util.regexify);
|
||||
|
||||
var fn;
|
||||
|
||||
if (commander.outDir) {
|
||||
fn = require("./dir");
|
||||
} else {
|
||||
fn = require("./file");
|
||||
}
|
||||
|
||||
fn(commander, filenames, exports.opts);
|
42
node_modules/babel/bin/babel/util.js
generated
vendored
Normal file
42
node_modules/babel/bin/babel/util.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
var readdir = require("fs-readdir-recursive");
|
||||
var index = require("./index");
|
||||
var babel = require("babel-core");
|
||||
var util = require("babel-core").util;
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
exports.readdirFilter = function (filename) {
|
||||
return readdir(filename).filter(function (filename) {
|
||||
return util.canCompile(filename);
|
||||
});
|
||||
};
|
||||
|
||||
exports.readdir = readdir;
|
||||
|
||||
exports.canCompile = util.canCompile;
|
||||
|
||||
exports.shouldIgnore = function (loc) {
|
||||
return util.shouldIgnore(loc, index.opts.ignore, index.opts.only);
|
||||
};
|
||||
|
||||
exports.addSourceMappingUrl = function (code, loc) {
|
||||
return code + "\n//# sourceMappingURL=" + path.basename(loc);
|
||||
};
|
||||
|
||||
exports.transform = function (filename, code, opts) {
|
||||
opts = _.defaults(opts || {}, index.opts);
|
||||
opts.filename = filename;
|
||||
opts.ignore = null;
|
||||
opts.only = null;
|
||||
|
||||
var result = babel.transform(code, opts);
|
||||
result.filename = filename;
|
||||
result.actual = code;
|
||||
return result;
|
||||
};
|
||||
|
||||
exports.compile = function (filename, opts) {
|
||||
var code = fs.readFileSync(filename, "utf8");
|
||||
return exports.transform(filename, code, opts);
|
||||
};
|
Reference in New Issue
Block a user