Skip to content

Commit

Permalink
Asyncify gulpfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
aomarks committed Nov 29, 2017
1 parent 4a66f62 commit 9c00f7e
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const {PolymerProject, HtmlSplitter} = require('polymer-build');

const {Transform} = require('stream');

const {promisify} = require('util');
const writeFile = promisify(fs.writeFile);
const readFile = promisify(fs.readFile);

class BackfillStream extends Transform {
constructor(fileList) {
super({objectMode: true});
Expand Down Expand Up @@ -260,21 +264,22 @@ gulp.task('lint', (done) => {
runseq('lint-eslint', 'lint-closure', done);
});

gulp.task('generate-externs', ['clean'], () => {
gulp.task('generate-externs', ['clean'], async () => {
let genClosure = require('@polymer/gen-closure-declarations').generateDeclarations;
return genClosure().then((declarations) => {
fs.writeFileSync('externs/closure-types.js', `${header}${declarations}`);
});
const declarations = await genClosure();
await writeFile('externs/closure-types.js', `${header}${declarations}`);
});

gulp.task('generate-typescript', () => {
gulp.task('generate-typescript', async () => {
let genTs = require('@polymer/gen-typescript-declarations').generateDeclarations;
del.sync(['**/*.d.ts']);
return genTs('.', JSON.parse(fs.readFileSync('gen-tsd.json'))).then((files) => {
for (const [path, contents] of files) {
fs.writeFileSync(path, contents);
}
});
await del(['**/*.d.ts']);
const config = JSON.parse(await readFile('gen-tsd.json'));
const files = await genTs('.', config);
const writes = [];
for (const [path, contents] of files) {
writes.push(writeFile(path, contents));
}
await Promise.all(writes);
});

gulp.task('update-version', () => {
Expand Down

0 comments on commit 9c00f7e

Please sign in to comment.