Skip to content

Commit

Permalink
build: Add new lines to "*.js" and "*.mjs" files (#1892)
Browse files Browse the repository at this point in the history
Makes "*.js" and "*.mjs" consistend with "*.js.flow" files and also
prevent diff artifacts, e.g.: cf36cdb#diff-0e28dd92524e3516b49eb5b753822f10R45
  • Loading branch information
IvanGoncharov committed May 22, 2019
1 parent e8dfa8b commit 87c6488
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions resources/build.js
Expand Up @@ -36,15 +36,17 @@ if (require.main === module) {
}
}

function babelBuild(srcPath, envName) {
return babel.transformFileSync(srcPath, { envName }).code + '\n';
}

function buildJSFile(filepath) {
const srcPath = path.join('./src', filepath);
const destPath = path.join('./dist', filepath);
const cjs = babel.transformFileSync(srcPath, { envName: 'cjs' });
const mjs = babel.transformFileSync(srcPath, { envName: 'mjs' });

copyFile(srcPath, destPath + '.flow');
writeFile(destPath, cjs.code);
writeFile(destPath.replace(/\.js$/, '.mjs'), mjs.code);
writeFile(destPath, babelBuild(srcPath, 'cjs'));
writeFile(destPath.replace(/\.js$/, '.mjs'), babelBuild(srcPath, 'mjs'));
}

function buildPackageJSON() {
Expand Down

0 comments on commit 87c6488

Please sign in to comment.