1
1
const fse = require ( 'fs-extra' ) ;
2
- const glob = require ( 'glob' ) ;
2
+ const { globSync } = require ( 'glob' ) ;
3
3
const path = require ( 'path' ) ;
4
4
5
5
const root = process . cwd ( ) ;
6
6
7
- const sourceFiles = glob
8
- . sync ( `${ root } /src/*/` )
7
+ const sourceFiles = globSync ( `${ root } /src/*/` )
9
8
. map ( ( name ) => name . replace ( / \/ $ / , '' ) ) ;
10
9
11
- const indexTypings = glob . sync ( `${ root } /src/index.d.ts` ) ;
10
+ const indexTypings = globSync ( `${ root } /src/index.d.ts` ) ;
12
11
13
12
async function copyTypings ( files , dest ) {
14
13
const cmds = [ ] ;
@@ -21,7 +20,7 @@ async function copyTypings(files, dest) {
21
20
22
21
async function createPackage ( file ) {
23
22
const fileName = file . split ( '/' ) . pop ( ) ;
24
- const esmSource = glob . sync ( `${ root } /esm/${ fileName } /**/index.js` ) [ 0 ] ;
23
+ const esmSource = globSync ( `${ root } /esm/${ fileName } /**/index.js` ) [ 0 ] ;
25
24
/**
26
25
* Prevent creating package.json for directories with no JS files (like CSS directories)
27
26
*/
@@ -36,7 +35,7 @@ async function createPackage(file) {
36
35
main : 'index.js' ,
37
36
module : esmRelative ,
38
37
} ;
39
- const typings = glob . sync ( `${ root } /src/${ fileName } /*.d.ts` ) ;
38
+ const typings = globSync ( `${ root } /src/${ fileName } /*.d.ts` ) ;
40
39
const cmds = [ ] ;
41
40
content . typings = 'index.d.ts' ;
42
41
cmds . push ( copyTypings ( typings , `${ root } /${ fileName } ` ) ) ;
@@ -56,6 +55,7 @@ async function run(files) {
56
55
copyTypings ( indexTypings , root ) ;
57
56
}
58
57
} catch ( error ) {
58
+ // eslint-disable-next-line no-console
59
59
console . error ( error ) ;
60
60
process . exit ( 1 ) ;
61
61
}
0 commit comments