Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function transpile(src, stack) {
var target = createTargetName(src);
babel.transformFile(src, babelOptions, function (err, result) {
if (err) { return console.log(err.codeFrame); }
fse.outputFile(target, result.code, function(err) {
if (err) { return console.error(err.message); }
console.log(util.format(green + '=> "%s" successfully transpiled to "%s"' + NC, src, target));
// next
if (stack && stack.length) {
transpile(stack.shift(), stack);
}
});
});
}
export function packageJS(inPath: string, outPath: string, callback: any = Function.prototype) {
transformFile(inPath, {loose: 'all', optional: ['runtime']}, function processCompiledJS(e, result) {
if (e) {
return consoleError(e);
}
fs.writeFile(outPath, result.code, function jsWriteScriptHandler(saveErr) {
if (saveErr) {
return consoleError(saveErr);
}
console.log('\x1b[32m%s: Compiled %s\x1b[0m', ++i, inPath);
callback();
});
});
}
function transform(filepath) {
babel.transformFile(filepath, {modules: 'umd'}, function (err,res) {
if (err) {
return console.log(err);
} else {
lint(res.code);
build(res.code);
}
});
}
function transpile(src) {
var target = createTargetName(src);
babel.transformFile(src, babelOptions, function(err, res) {
if (err) { return console.log(err.message); }
fse.outputFile(target, res.code, function(err, res) {
if (err) { return console.log(err.message); }
console.log(util.format(green + '=> "%s" successfully transpiled to "%s"' + NC, src, target));
});
});
}
'use strict';
var fs = require('fs');
var babel = require('babel');
if (!fs.existsSync('./es5')) {
fs.mkdirSync('./es5');
}
babel.transformFile('index.js', {'loose': ['es6.classes']}, function (err, result) {
if (err) { console.log('Error : ' + err.message); }
fs.writeFileSync('./es5/index.js', result.code);
});
function transform(filepath) {
babel.transformFile(filepath, {modules: 'umd'}, function (err,res) {
if (err) {
return console.log(err);
} else {
lint(res.code);
build(res.code);
}
});
}
function transform(filepath) {
babel.transformFile(filepath, {modules: 'umd'}, function (err,res) {
if (err) {
return console.log(err);
} else {
lint(res.code);
build(res.code);
}
});
}
Insync.each(files, function (file, next) {
Babel.transformFile(file.input, options, function (err, result) {
if (err) {
return next(err);
}
Fse.outputFile(file.output, result.code, next);
});
}, callback);
};