Merge pull request #8201 from ahocevar/no-babelrc

Remove babelrc, transform using babel-core
This commit is contained in:
Andreas Hocevar
2018-05-21 03:52:00 -05:00
committed by GitHub
3 changed files with 35 additions and 12 deletions

31
tasks/transform-types.js Normal file
View File

@@ -0,0 +1,31 @@
/**
* @filedesc
* Transforms type comments in all source files to types that Closure Compiler
* understands.
*/
const glob = require('glob');
const mkdirp = require('mkdirp').sync;
const fs = require('fs');
const path = require('path');
const transform = require('babel-core').transformFileSync;
const options = {
plugins: 'jsdoc-closure',
parserOpts: {
parser: 'recast'
},
generatorOpts: {
generator: 'recast'
}
};
const outDir = path.join('build', 'src-closure');
glob('src/**/*.js', (err, matches) => {
matches.forEach(match => {
const out = path.join(outDir, path.relative('src', match));
mkdirp(path.dirname(out));
fs.writeFileSync(out, transform(match, options).code, 'utf-8');
});
});