Path: blob/trunk/javascript/private/closure_make_deps_wrapper.js
4503 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617/**18* Wrapper for closure-make-deps that reads file arguments from a response file.19*20* This avoids Windows command line length limits by reading the file list from21* a file instead of passing them as command line arguments.22*23* Usage: closure_make_deps_wrapper.js <files_list> <output> <closure_path>24*/2526const fs = require('fs');27const path = require('path');28const closureMakeDeps = require('google-closure-deps').closureMakeDeps;2930async function main() {31const args = process.argv.slice(2);3233if (args.length < 3) {34console.error(35'Usage: closure_make_deps_wrapper.js <files_list> <output> <closure_path>');36process.exit(1);37}3839const [filesListPath, outputPath, closurePath] = args;4041const filesContent = fs.readFileSync(filesListPath, 'utf8');42const files = filesContent.trim().split('\n').filter(f => f.length > 0);4344const cliArgs = [45'--closure-path', closurePath,46'--no-validate',47...files.flatMap(f => ['--file', f]),48];4950try {51const result = await closureMakeDeps.execute(cliArgs);5253for (const error of result.errors) {54console.error(error.toString());55}5657if (result.text) {58fs.writeFileSync(outputPath, result.text);59} else {60process.exit(1);61}62} catch (e) {63console.error(e);64process.exit(1);65}66}6768main();697071