@@ -32,16 +32,15 @@ const {sync: globSync} = require('glob');
32
32
33
33
const PKG_RE = / ^ ( ( [ a - z ] * \- ? ) * ) / ;
34
34
35
- const isValidCwd = (
35
+ const isValidCwd =
36
36
path . basename ( process . cwd ( ) ) === 'material-components-web-react' &&
37
37
fs . existsSync ( 'packages' ) &&
38
- fs . existsSync ( 'build' )
39
- ) ;
38
+ fs . existsSync ( 'build' ) ;
40
39
41
40
if ( ! isValidCwd ) {
42
41
console . error (
43
42
'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`'
45
44
) ;
46
45
process . exit ( 0 ) ;
47
46
}
@@ -54,7 +53,9 @@ function getAssetEntry(asset) {
54
53
function cpAsset ( asset ) {
55
54
const assetPkg = path . join ( 'packages' , getAssetEntry ( asset ) ) ;
56
55
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
+ ) ;
58
59
}
59
60
60
61
let basename = path . basename ( asset ) ;
@@ -71,16 +72,20 @@ function cpAsset(asset) {
71
72
}
72
73
73
74
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
+ ) ;
76
78
}
77
79
78
80
// this takes a file path to an index.d.ts file and adds an //@ts -ignore comment
79
81
// above the MDC Web imports (any line that includes `/dist/`). We need to ignore
80
82
// these lines since MDC Web does not have typing files
81
83
// TODO: https://github.com/material-components/material-components-web-react/issues/574
82
84
function addTsIgnore ( filePath ) {
83
- const data = fs . readFileSync ( filePath ) . toString ( ) . split ( '\n' ) ;
85
+ const data = fs
86
+ . readFileSync ( filePath )
87
+ . toString ( )
88
+ . split ( '\n' ) ;
84
89
const lineNumber = data . findIndex ( ( lineText ) => lineText . includes ( '/dist/' ) ) ;
85
90
if ( lineNumber <= - 1 ) return ;
86
91
@@ -100,8 +105,9 @@ function cpTypes(typeAsset) {
100
105
destDir . splice ( 2 , 0 , 'dist' ) ;
101
106
destDir = `${ destDir . join ( '/' ) } /${ base } ` ;
102
107
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
+ ) ;
105
111
}
106
112
107
113
async function copyPackages ( ) {
@@ -117,4 +123,3 @@ async function copyPackages() {
117
123
}
118
124
119
125
copyPackages ( ) ;
120
-
0 commit comments