1
- import { prettifyPackageDistJson , prettifyPackageJson , prettifyReadme , prettifySrc } from "./build-prettier" ;
2
1
import { Command } from "commander" ;
3
- import { buildDistFiles } from "./build-distfiles" ;
4
- import { buildTS } from "./build-tsc" ;
5
- import { bundle } from "./build-bundle" ;
6
- import { clearDist } from "./build-clear" ;
7
- import fs from "fs-extra" ;
8
- import { getDistStats } from "./build-diststats" ;
9
- import { lint } from "./build-eslint" ;
10
- import path from "path" ;
11
2
12
3
const buildCommand = new Command ( "build" ) ;
13
4
@@ -42,13 +33,18 @@ buildCommand.action(async (argPath: string) => {
42
33
tsc = all || ! ! opts . tsc ;
43
34
44
35
const basePath = process . cwd ( ) ,
36
+ { getDistStats } = await import ( "./build-diststats.js" ) ,
45
37
oldStats = await getDistStats ( basePath ) ;
46
38
47
39
if ( clean ) {
40
+ const { clearDist } = await import ( "./build-clear.js" ) ;
41
+
48
42
await clearDist ( basePath ) ;
49
43
}
50
44
51
- const srcPath = path . join ( basePath , argPath ) ;
45
+ const path = await import ( "path" ) ,
46
+ srcPath = path . join ( basePath , argPath ) ,
47
+ fs = await import ( "fs-extra" ) ;
52
48
53
49
if ( ! ( await fs . pathExists ( srcPath ) ) ) {
54
50
throw new Error ( "Provided path does not exist" ) ;
@@ -57,28 +53,40 @@ buildCommand.action(async (argPath: string) => {
57
53
let canContinue = true ;
58
54
59
55
if ( canContinue && prettier ) {
56
+ const { prettifySrc } = await import ( "./build-prettier.js" ) ;
57
+
60
58
canContinue = await prettifySrc ( basePath , srcPath , ci ) ;
61
59
}
62
60
63
61
if ( canContinue && doLint ) {
62
+ const { lint } = await import ( "./build-eslint.js" ) ;
63
+
64
64
canContinue = await lint ( ci ) ;
65
65
}
66
66
67
67
if ( canContinue && tsc ) {
68
+ const { buildTS } = await import ( "./build-tsc.js" ) ;
69
+
68
70
canContinue = await buildTS ( basePath ) ;
69
71
}
70
72
71
73
if ( canContinue && doBundle ) {
74
+ const { bundle } = await import ( "./build-bundle.js" ) ;
75
+
72
76
canContinue = await bundle ( basePath ) ;
73
77
}
74
78
75
79
if ( canContinue && prettier ) {
80
+ const { prettifyReadme, prettifyPackageJson, prettifyPackageDistJson } = await import ( "./build-prettier" ) ;
81
+
76
82
canContinue = await prettifyReadme ( basePath , ci ) ;
77
83
canContinue = await prettifyPackageJson ( basePath , ci ) ;
78
84
canContinue = await prettifyPackageDistJson ( basePath , ci ) ;
79
85
}
80
86
81
87
if ( canContinue && distfiles ) {
88
+ const { buildDistFiles } = await import ( "./build-distfiles.js" ) ;
89
+
82
90
canContinue = await buildDistFiles ( basePath ) ;
83
91
}
84
92
0 commit comments