@@ -3,61 +3,51 @@ import { parseArgs } from "node:util";
3
3
import { resolve } from "node:path" ;
4
4
5
5
export function getArgs ( ) : {
6
- skipBuild : boolean ;
7
- outputDir ?: string ;
6
+ skipBuild : boolean ;
7
+ outputDir ?: string ;
8
8
} {
9
- const {
10
- values : { skipBuild, output } ,
11
- } = parseArgs ( {
12
- options : {
13
- skipBuild : {
14
- type : "boolean" ,
15
- short : "s" ,
16
- default : false ,
17
- } ,
18
- output : {
19
- type : "string" ,
20
- short : "o" ,
21
- } ,
22
- } ,
23
- allowPositionals : false ,
24
- } ) ;
9
+ const {
10
+ values : { skipBuild, output } ,
11
+ } = parseArgs ( {
12
+ options : {
13
+ skipBuild : {
14
+ type : "boolean" ,
15
+ short : "s" ,
16
+ default : false ,
17
+ } ,
18
+ output : {
19
+ type : "string" ,
20
+ short : "o" ,
21
+ } ,
22
+ } ,
23
+ allowPositionals : false ,
24
+ } ) ;
25
25
26
- const outputDir = output ? resolve ( output ) : undefined ;
26
+ const outputDir = output ? resolve ( output ) : undefined ;
27
27
28
- if ( outputDir ) {
29
- assertDirArg ( outputDir , "output" , true ) ;
30
- }
28
+ if ( outputDir ) {
29
+ assertDirArg ( outputDir , "output" , true ) ;
30
+ }
31
31
32
- return {
33
- outputDir,
34
- skipBuild :
35
- skipBuild ||
36
- [ "1" , "true" , "yes" ] . includes ( String ( process . env . SKIP_NEXT_APP_BUILD ) ) ,
37
- } ;
32
+ return {
33
+ outputDir,
34
+ skipBuild : skipBuild || [ "1" , "true" , "yes" ] . includes ( String ( process . env . SKIP_NEXT_APP_BUILD ) ) ,
35
+ } ;
38
36
}
39
37
40
38
function assertDirArg ( path : string , argName ?: string , make ?: boolean ) {
41
- let dirStats : Stats ;
42
- try {
43
- dirStats = statSync ( path ) ;
44
- } catch {
45
- if ( ! make ) {
46
- throw new Error (
47
- `Error: the provided${
48
- argName ? ` "${ argName } "` : ""
49
- } input is not a valid path`
50
- ) ;
51
- }
52
- mkdirSync ( path ) ;
53
- return ;
54
- }
39
+ let dirStats : Stats ;
40
+ try {
41
+ dirStats = statSync ( path ) ;
42
+ } catch {
43
+ if ( ! make ) {
44
+ throw new Error ( `Error: the provided${ argName ? ` "${ argName } "` : "" } input is not a valid path` ) ;
45
+ }
46
+ mkdirSync ( path ) ;
47
+ return ;
48
+ }
55
49
56
- if ( ! dirStats . isDirectory ( ) ) {
57
- throw new Error (
58
- `Error: the provided${
59
- argName ? ` "${ argName } "` : ""
60
- } input is not a directory`
61
- ) ;
62
- }
50
+ if ( ! dirStats . isDirectory ( ) ) {
51
+ throw new Error ( `Error: the provided${ argName ? ` "${ argName } "` : "" } input is not a directory` ) ;
52
+ }
63
53
}
0 commit comments