@@ -32,16 +32,15 @@ const {sync: globSync} = require('glob');
3232
3333const PKG_RE = / ^ ( ( [ a - z ] * \- ? ) * ) / ;
3434
35- const isValidCwd = (
35+ const isValidCwd =
3636 path . basename ( process . cwd ( ) ) === 'material-components-web-react' &&
3737 fs . existsSync ( 'packages' ) &&
38- fs . existsSync ( 'build' )
39- ) ;
38+ fs . existsSync ( 'build' ) ;
4039
4140if ( ! isValidCwd ) {
4241 console . error (
4342 'Invalid CWD. Please ensure you are running this from the root of the repo, ' +
44- 'and that you have run `npm run build`'
43+ 'and that you have run `npm run build`'
4544 ) ;
4645 process . exit ( 0 ) ;
4746}
@@ -54,7 +53,9 @@ function getAssetEntry(asset) {
5453function cpAsset ( asset ) {
5554 const assetPkg = path . join ( 'packages' , getAssetEntry ( asset ) ) ;
5655 if ( ! fs . existsSync ( assetPkg ) ) {
57- Promise . reject ( new Error ( `Non-existent asset package path ${ assetPkg } for ${ asset } ` ) ) ;
56+ Promise . reject (
57+ new Error ( `Non-existent asset package path ${ assetPkg } for ${ asset } ` )
58+ ) ;
5859 }
5960
6061 let basename = path . basename ( asset ) ;
@@ -71,16 +72,20 @@ function cpAsset(asset) {
7172 }
7273
7374 const destDir = path . join ( assetPkg , 'dist' , basename ) ;
74- return cpFile ( asset , destDir )
75- . then ( ( ) => console . log ( `cp ${ asset } -> ${ destDir } ` ) ) ;
75+ return cpFile ( asset , destDir ) . then ( ( ) =>
76+ console . log ( `cp ${ asset } -> ${ destDir } ` )
77+ ) ;
7678}
7779
7880// this takes a file path to an index.d.ts file and adds an //@ts -ignore comment
7981// above the MDC Web imports (any line that includes `/dist/`). We need to ignore
8082// these lines since MDC Web does not have typing files
8183// TODO: https://github.com/material-components/material-components-web-react/issues/574
8284function addTsIgnore ( filePath ) {
83- const data = fs . readFileSync ( filePath ) . toString ( ) . split ( '\n' ) ;
85+ const data = fs
86+ . readFileSync ( filePath )
87+ . toString ( )
88+ . split ( '\n' ) ;
8489 const lineNumber = data . findIndex ( ( lineText ) => lineText . includes ( '/dist/' ) ) ;
8590 if ( lineNumber <= - 1 ) return ;
8691
@@ -100,8 +105,9 @@ function cpTypes(typeAsset) {
100105 destDir . splice ( 2 , 0 , 'dist' ) ;
101106 destDir = `${ destDir . join ( '/' ) } /${ base } ` ;
102107 addTsIgnore ( typeAsset ) ;
103- return cpFile ( typeAsset , destDir )
104- . then ( ( ) => console . log ( `cp ${ typeAsset } -> ${ destDir } ` ) ) ;
108+ return cpFile ( typeAsset , destDir ) . then ( ( ) =>
109+ console . log ( `cp ${ typeAsset } -> ${ destDir } ` )
110+ ) ;
105111}
106112
107113async function copyPackages ( ) {
@@ -117,4 +123,3 @@ async function copyPackages() {
117123}
118124
119125copyPackages ( ) ;
120-
0 commit comments