gts
Version:
Google TypeScript Style
46 lines • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.clean = clean;
/**
* Copyright 2017 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const chalk = require("chalk");
const fs = require("fs");
const util_1 = require("./util");
/**
* Remove files generated by the build.
*/
async function clean(options) {
const tsconfig = (await (0, util_1.getTSConfig)(options.targetRootDir));
if (tsconfig.compilerOptions && tsconfig.compilerOptions.outDir) {
const outDir = tsconfig.compilerOptions.outDir;
if (outDir === '.') {
options.logger.error(`${chalk.red('ERROR:')} ${chalk.gray('compilerOptions.outDir')} ` +
'cannot use the value ".". That would delete all of our sources.');
return false;
}
const message = `${chalk.red('Removing')} ${outDir} ...`;
options.logger.log(message);
await fs.promises.rm(outDir, { recursive: true, force: true });
return true;
}
else {
options.logger.error(`${chalk.red('ERROR:')} The ${chalk.gray('clean')} command` +
` requires ${chalk.gray('compilerOptions.outDir')} to be defined in ` +
'tsconfig.json.');
return false;
}
}
//# sourceMappingURL=clean.js.map