Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function convertFile(inFile, outFile) {
console.log('Converting', inFile);
let js;
try {
js = decaffeinate.convert(fs.readFileSync(inFile).toString('utf8'));
} catch (err) {
return Promise.reject(err);
}
return reformat(js).then(result => {
fs.writeFileSync(outFile, result);
});
}
fs.readFile(fileName, (err, file) => {
if (err) {
console.log(`Could not read ${fileName}: ${err}`);
return stats.report('failureRead', fileName);
}
const coffeeScript = file.toString();
let es6;
try {
es6 = decaffeinate.convert(coffeeScript).code;
} catch (err) {
console.log(`Could not decaffeinate ${fileName}: ${err}`);
return stats.report('failureDecaffeinate', fileName);
}
let typescript;
try {
typescript = jsToTs(es6);
} catch (err) {
console.log(`Could not convert ${fileName}:`);
console.error(err.stack);
return stats.report('failureSelf', fileName);
}
const outputFileName = fileName.replace(/\.coffee$/, '.ts');
fs.writeFile(outputFileName, typescript, function (err) {
fs.readFile(fileName, function (err, file) {
if (err) {
console.log('Could not read ' + fileName + ': ' + err);
return stats.report('failureRead', fileName);
}
var coffeeScript = file.toString();
var es6 = void 0;
try {
es6 = decaffeinate.convert(coffeeScript).code;
} catch (err) {
console.log('Could not decaffeinate ' + fileName + ': ' + err);
return stats.report('failureDecaffeinate', fileName);
}
var typescript = void 0;
try {
typescript = jsToTs(es6);
} catch (err) {
console.log('Could not convert ' + fileName + ':');
console.error(err.stack);
return stats.report('failureSelf', fileName);
}
var outputFileName = fileName.replace(/\.coffee$/, '.ts');
fs.writeFile(outputFileName, typescript, function (err) {