Files
angular__angular/tools/sass-bundle.ts
T
Kristiyan Kostadinov 9e05af3aa4 build: add tslint rule for consistent file name casing (#14536)
Adds a tslint rule to enforce that the casing on our filenames is consistent. The tslint rule files are excluded, because their names have to be in camel case and end with `Rule`.
2018-12-17 20:15:24 -08:00

36 lines
1.1 KiB
TypeScript

import {writeFileSync} from 'fs';
import {join} from 'path';
const Bundler = require('scss-bundle').Bundler;
const minimist = require('minimist');
/** The root of the bazel workspace (sandbox). */
const workspaceRoot = process.cwd();
/**
* Bundles sass partials into a single file using the `scss-bundle` package. This does not use the
* default CLI for `scss-bundle` to give us a place to introspect / debug values coming from
* bazel if necessary.
*/
export async function main(args: string[]): Promise<number> {
const parsedArgs: {srcs: string, output: string, entry: string} = minimist(args);
const inputFiles = parsedArgs.srcs.split(',');
return new Bundler().Bundle(join(workspaceRoot, parsedArgs.entry), inputFiles).then(result => {
writeFileSync(parsedArgs.output, result.bundledContent);
return 0;
}).catch(error => {
console.error('Sass bundling failed');
console.dir(error);
return 1;
});
}
if (require.main === module) {
const args = process.argv.slice(2);
main(args).then(exitCode => {
process.exitCode = exitCode;
});
}