Skip to content

Commit 87c6488

Browse files
build: Add new lines to "*.js" and "*.mjs" files (#1892)
Makes "*.js" and "*.mjs" consistend with "*.js.flow" files and also prevent diff artifacts, e.g.: cf36cdb#diff-0e28dd92524e3516b49eb5b753822f10R45
1 parent e8dfa8b commit 87c6488

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

resources/build.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ if (require.main === module) {
3636
}
3737
}
3838

39+
function babelBuild(srcPath, envName) {
40+
return babel.transformFileSync(srcPath, { envName }).code + '\n';
41+
}
42+
3943
function buildJSFile(filepath) {
4044
const srcPath = path.join('./src', filepath);
4145
const destPath = path.join('./dist', filepath);
42-
const cjs = babel.transformFileSync(srcPath, { envName: 'cjs' });
43-
const mjs = babel.transformFileSync(srcPath, { envName: 'mjs' });
4446

4547
copyFile(srcPath, destPath + '.flow');
46-
writeFile(destPath, cjs.code);
47-
writeFile(destPath.replace(/\.js$/, '.mjs'), mjs.code);
48+
writeFile(destPath, babelBuild(srcPath, 'cjs'));
49+
writeFile(destPath.replace(/\.js$/, '.mjs'), babelBuild(srcPath, 'mjs'));
4850
}
4951

5052
function buildPackageJSON() {

0 commit comments

Comments
 (0)