File tree Expand file tree Collapse file tree 3 files changed +39
-4
lines changed
Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ node_modules
33! web-test-runner.config.js
44! commitlint.config.js
55* .css
6+ * .cssresult.ts
67* -styles.ts
78* .map
89* .d.ts
Original file line number Diff line number Diff line change 113113 ]
114114 },
115115 "build:css-to-ts" : {
116+ "dependencies" : [
117+ " build:css-to-ts:cssresult" ,
118+ " build:css-to-ts:styles"
119+ ]
120+ },
121+ "build:css-to-ts:cssresult" : {
122+ "command" : " find . \\ ( -path ./.wireit -o -path ./node_modules -o -path ./catalog \\ ) -prune -o -name '*.css' -print | xargs -L1 node scripts/css-to-ts.js --suffix=.cssresult" ,
123+ "files" : [
124+ " **/*.css" ,
125+ " !catalog/"
126+ ],
127+ "output" : [
128+ " **/*.cssresult.ts" ,
129+ " !catalog/"
130+ ],
131+ "dependencies" : [
132+ " build:scripts" ,
133+ " build:sass"
134+ ]
135+ },
136+ "build:css-to-ts:styles" : {
116137 "command" : " find . \\ ( -path ./.wireit -o -path ./node_modules -o -path ./catalog \\ ) -prune -o -name '*-styles.css' -print | xargs -L1 node scripts/css-to-ts.js" ,
117138 "files" : [
118139 " **/*-styles.css" ,
Original file line number Diff line number Diff line change 55 */
66
77import * as fs from 'fs' ;
8+ import * as util from 'util' ;
89
9- const cssFilePath = process . argv [ 2 ] ;
10+ const { values, positionals} = util . parseArgs ( {
11+ allowPositionals : true ,
12+ options : {
13+ suffix : {
14+ type : 'string' ,
15+ } ,
16+ } ,
17+ } ) ;
18+
19+ const cssFilePath = positionals [ 0 ] ;
1020if ( ! cssFilePath ) {
11- throw new Error ( `Usage: node scripts/css-to-ts.js <input.css> [output.ts]` ) ;
21+ throw new Error (
22+ `Usage: node scripts/css-to-ts.js <input.css> [output.ts] [--suffix=<suffix>]` ,
23+ ) ;
1224}
1325
14- const tsFilePath = process . argv [ 3 ] || cssFilePath . replace ( '.css' , '.ts' ) ;
26+ const tsFilePath =
27+ positionals [ 1 ] || cssFilePath . replace ( '.css' , `${ values . suffix || '' } .ts` ) ;
1528const cssContent = fs
1629 . readFileSync ( cssFilePath , { encoding : 'utf8' } )
1730 // Remove source map comments since the css is embedded.
@@ -22,7 +35,7 @@ fs.writeFileSync(
2235 tsFilePath ,
2336 `/**
2437 * @license
25- * Copyright 2024 Google LLC
38+ * Copyright ${ new Date ( ) . getFullYear ( ) } Google LLC
2639 * SPDX-License-Identifier: Apache-2.0
2740 */
2841// Generated stylesheet for ${ cssFilePath } .
You can’t perform that action at this time.
0 commit comments