-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
gulpfile.js
41 lines (36 loc) · 1.33 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { dest, series, src } = require('gulp')
const babel = require('gulp-babel')
const { resolve } = require('path')
const { promisify } = require('util')
const execFile = promisify(require('child_process').execFile)
const writeFile = promisify(require('fs').writeFile)
const compiler = () =>
src('packages/compiler/src/*.js')
.pipe(babel())
.pipe(dest('packages/compiler/lib/'))
const cli = () =>
src('packages/cli/src/*').pipe(babel()).pipe(dest('packages/cli/lib/'))
const makePluralCmd = resolve('packages/cli/make-plural')
const pluralDest = resolve('packages/plurals')
async function plurals(cb) {
for (const [tgt, tgtOpt] of Object.entries({
cardinals: ['plurals', '--no-ordinals'],
ordinals: ['plurals', '--no-cardinals'],
plurals: ['plurals'],
pluralCategories: ['categories'],
examples: ['examples'],
ranges: ['ranges', '--max-repeat=3']
})) {
for (const [ext, extOpt] of Object.entries({
'd.ts': ['--dts'],
js: ['--umd'],
mjs: []
})) {
const { stdout } = await execFile(makePluralCmd, [...tgtOpt, ...extOpt])
await writeFile(resolve(pluralDest, `${tgt}.${ext}`), stdout)
}
}
const { stdout } = await execFile(makePluralCmd, ['examples', '--json'])
await writeFile(resolve(pluralDest, 'examples.json'), stdout)
}
exports.default = series(compiler, cli, plurals)