|
15 | 15 | *
|
16 | 16 | */
|
17 | 17 |
|
18 |
| -const _gulp = require('gulp'); |
19 |
| -const help = require('gulp-help'); |
| 18 | +import * as _gulp from 'gulp'; |
| 19 | +import * as help from 'gulp-help'; |
20 | 20 |
|
21 | 21 | // gulp-help monkeypatches tasks to have an additional description parameter
|
22 | 22 | const gulp = help(_gulp);
|
23 | 23 |
|
24 |
| -var runSequence = require('run-sequence'); |
| 24 | +const runSequence = require('run-sequence'); |
25 | 25 |
|
26 |
| -require('./packages/grpc-health-check/gulpfile'); |
27 |
| -require('./packages/grpc-js/gulpfile'); |
28 |
| -require('./packages/grpc-js-core/gulpfile'); |
29 |
| -require('./packages/grpc-native/gulpfile'); |
30 |
| -require('./packages/grpc-native-core/gulpfile'); |
31 |
| -require('./packages/grpc-surface/gulpfile'); |
32 |
| -require('./test/gulpfile'); |
| 26 | +/** |
| 27 | + * Require a module at the given path with a patched gulp object that prepends |
| 28 | + * the given prefix to each task name. |
| 29 | + * @param path The path to require. |
| 30 | + * @param prefix The string to use as a prefix. This will be prepended to a task |
| 31 | + * name with a '.' separator. |
| 32 | + */ |
| 33 | +function loadGulpTasksWithPrefix(path: string, prefix: string) { |
| 34 | + const gulpTask = gulp.task; |
| 35 | + gulp.task = ((taskName: string, ...args: any[]) => { |
| 36 | + // Don't create a task for ${prefix}.help |
| 37 | + if (taskName === 'help') { |
| 38 | + return; |
| 39 | + } |
| 40 | + // The only array passed to gulp.task must be a list of dependent tasks. |
| 41 | + const newArgs = args.map(arg => Array.isArray(arg) ? |
| 42 | + arg.map(dep => `${prefix}.${dep}`) : arg); |
| 43 | + gulpTask(`${prefix}.${taskName}`, ...newArgs); |
| 44 | + }); |
| 45 | + const result = require(path); |
| 46 | + gulp.task = gulpTask; |
| 47 | + return result; |
| 48 | +} |
| 49 | + |
| 50 | +[ |
| 51 | + ['./packages/grpc-health-check/gulpfile', 'health-check'], |
| 52 | + ['./packages/grpc-js/gulpfile', 'js'], |
| 53 | + ['./packages/grpc-js-core/gulpfile', 'js.core'], |
| 54 | + ['./packages/grpc-native/gulpfile', 'native'], |
| 55 | + ['./packages/grpc-native-core/gulpfile', 'native.core'], |
| 56 | + ['./packages/grpc-surface/gulpfile', 'surface'], |
| 57 | + ['./test/gulpfile', 'internal.test'] |
| 58 | +].forEach((args) => loadGulpTasksWithPrefix(args[0], args[1])); |
33 | 59 |
|
34 | 60 | const root = __dirname;
|
35 | 61 |
|
36 | 62 | gulp.task('install.all', 'Install dependencies for all subdirectory packages',
|
37 |
| - ['js.core.install', 'native.core.install', 'surface.install', 'health-check.install', 'internal.test.install']); |
| 63 | + ['js.install', 'js.core.install', 'native.core.install', 'surface.install', 'health-check.install', 'internal.test.install']); |
38 | 64 |
|
39 | 65 | gulp.task('install.all.windows', 'Install dependencies for all subdirectory packages for MS Windows',
|
40 | 66 | ['js.core.install', 'native.core.install.windows', 'surface.install', 'health-check.install', 'internal.test.install']);
|
41 | 67 |
|
42 | 68 | gulp.task('lint', 'Emit linting errors in source and test files',
|
43 | 69 | ['js.core.lint', 'native.core.lint']);
|
44 | 70 |
|
45 |
| -gulp.task('build', 'Build packages', ['js.core.compile', 'native.core.build']); |
| 71 | +gulp.task('build', 'Build packages', ['js.compile', 'js.core.compile', 'native.core.build']); |
46 | 72 |
|
47 |
| -gulp.task('core.link', 'Add links to core packages without rebuilding', |
| 73 | +gulp.task('link.core', 'Add links to core packages without rebuilding', |
48 | 74 | ['js.link.add', 'native.link.add']);
|
49 | 75 |
|
50 |
| -gulp.task('surface.link', 'Link to surface packages', |
| 76 | +gulp.task('link.surface', 'Link to surface packages', |
51 | 77 | ['health-check.link.add']);
|
52 | 78 |
|
53 | 79 | gulp.task('link', 'Link together packages', (callback) => {
|
54 |
| - /* Currently, the target 'surface.link.create' doesn't work properly, and it |
55 |
| - * is also not needed for the existing tests. The comment indicates where it |
56 |
| - * belongs in the sequence. See npm/npm#18835 for the primary problem with it. |
57 |
| - * This also means that 'core.link' is not needed, and the item |
58 |
| - * 'native.core.link.create' should actually be 'core.link.create' |
| 80 | + /** |
| 81 | + * We use workarounds for linking in some modules. See npm/npm#18835 |
59 | 82 | */
|
60 |
| - runSequence('core.link', 'surface.link', |
| 83 | + runSequence('link.core', 'link.surface', |
61 | 84 | callback);
|
62 | 85 | });
|
63 | 86 |
|
|
0 commit comments