This repository was archived by the owner on Aug 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathgenerate_deps_js.js
executable file
·85 lines (76 loc) · 2.02 KB
/
generate_deps_js.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview A utility to write deps.js for Closure Library.
*/
const {closureMakeDeps} = require('google-closure-deps');
const CLOSURE_PATH = 'closure/goog';
const THIRD_PARTY_PATH = 'third_party/closure/goog';
const HEADER = `
// Copyright The Closure Library Authors.
// SPDX-License-Identifier: Apache-2.0
// This file has been auto-generated, please do not edit.
// To regenerate, run \`npm run gen_deps_js\` in the root directory of the
// Closure Library git repository.
// Disable Clang formatter for this file.
// See http://goo.gl/SdiwZH
// clang-format off
`.trim();
/**
* Flags to add to closureMakeDeps in order to exclude tests.
*/
const TEST_EXCLUSION_FLAGS = [
'--exclude',
'**/*_test.js',
'--exclude',
'**/tester.js',
'--exclude',
'**/*_test_vectors.js',
'--exclude',
'**/*_test_suite.js',
'--exclude',
'**/*_test_cases.js',
'--exclude',
'**/testdata/**/*.js',
'--exclude',
`${CLOSURE_PATH}/demos/`,
];
/**
* Prints the generated deps.js contents.
* @param {!Array<string>} args Command-line arguments.
* @return {!Promise<number>} The exit code.
*/
async function main(args) {
try {
const genDepsWithTests = args.indexOf('--with_tests') != -1;
const {text, errors} = await closureMakeDeps.execute([
'--root',
CLOSURE_PATH,
'--root',
THIRD_PARTY_PATH,
...genDepsWithTests ? [] : TEST_EXCLUSION_FLAGS,
'--exclude',
`${CLOSURE_PATH}/deps*.js`,
'--exclude',
`${CLOSURE_PATH}/transpile.js`,
]);
// Print all encountered errors. Errors are not necessarily fatal.
for (const error of errors) {
console.error(error.toString());
}
if (text) {
console.log(`${HEADER}\n\n${text.trim()}`);
return 0;
} else {
// No text indicates that the errors were fatal.
return 1;
}
} catch (e) {
console.error(e);
return 1;
}
}
main(process.argv.slice(2)).then(code => process.exit(code));