Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const pkgSrc = utils.readJSONFile(path.join(source, 'package.json'));
const chaiVer = pkgSrc.dependencies['chai'];
const chaiTypeVer = pkgSrc.devDependencies['@types/chai'];
const target = path.resolve(process.argv[2]);
if (!target) {
console.error('Specify a target dir');
process.exit(1);
}
const targetPkg = utils.readJSONFile(path.join(target, 'package.json'));
delete targetPkg.dependencies['expect.js'];
targetPkg.dependencies['chai'] = chaiVer;
targetPkg.devDependencies['@types/chai'] = chaiTypeVer;
utils.writePackageData(path.join(target, 'package.json'), targetPkg);
glob.sync(path.join(target, 'src', '*.ts*')).forEach(function(filePath) {
let src = fs.readFileSync(filePath, 'utf8');
src = src
.split("import expect = require('expect.js')")
.join("import { expect } from 'chai'");
src = src.split('to.be(undefined)').join('to.be.undefined');
src = src.split('to.be(void 0)').join('to.be.undefined');
src = src.split('to.be(null)').join('to.be.null');
src = src.split('to.not.throwError(').join('to.not.throw(');
src = src.split('to.throwError(').join('to.throw(');
src = src.split('to.not.be.ok()').join('to.not.be.ok');
src = src.split('to.not.be.empty()').join('to.not.be.empty');
src = src.split('to.be(').join('to.equal(');
src = src.split('to.not.be(').join('to.not.equal(');
src = src.split('to.be.ok()').join('to.be.ok');