Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/javascript/private/closure_make_deps_wrapper.js
4004 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
/**
19
* Wrapper for closure-make-deps that reads file arguments from a response file.
20
*
21
* This avoids Windows command line length limits by reading the file list from
22
* a file instead of passing them as command line arguments.
23
*
24
* Usage: closure_make_deps_wrapper.js <files_list> <output> <closure_path>
25
*/
26
27
const fs = require('fs');
28
const path = require('path');
29
const closureMakeDeps = require('google-closure-deps').closureMakeDeps;
30
31
async function main() {
32
const args = process.argv.slice(2);
33
34
if (args.length < 3) {
35
console.error(
36
'Usage: closure_make_deps_wrapper.js <files_list> <output> <closure_path>');
37
process.exit(1);
38
}
39
40
const [filesListPath, outputPath, closurePath] = args;
41
42
const filesContent = fs.readFileSync(filesListPath, 'utf8');
43
const files = filesContent.trim().split('\n').filter(f => f.length > 0);
44
45
const cliArgs = [
46
'--closure-path', closurePath,
47
'--no-validate',
48
...files.flatMap(f => ['--file', f]),
49
];
50
51
try {
52
const result = await closureMakeDeps.execute(cliArgs);
53
54
for (const error of result.errors) {
55
console.error(error.toString());
56
}
57
58
if (result.text) {
59
fs.writeFileSync(outputPath, result.text);
60
} else {
61
process.exit(1);
62
}
63
} catch (e) {
64
console.error(e);
65
process.exit(1);
66
}
67
}
68
69
main();
70
71