@@ -34,21 +34,37 @@ function parseArgs() {
34
34
// 1: /…/src/scripts/build/package.ts
35
35
// 2: foo
36
36
37
+ const args : { [ key : string ] : any } = {
38
+ /** Produce an unoptimized VSIX. Include git SHA in version string. */
39
+ debug : false ,
40
+ /** Skips `npm run clean` when building the VSIX. This prevents file watching from breaking. */
41
+ skipClean : false ,
42
+ feature : '' ,
43
+ }
44
+
37
45
const givenArgs = process . argv . slice ( 2 )
38
- const validOptions = [ '--debug' , '--no-clean' ]
46
+ const validOptions = [ '--debug' , '--no-clean' , '--feature' ]
47
+ const expectValue = [ '--feature' ]
39
48
40
- for ( const a of givenArgs ) {
49
+ for ( let i = 0 ; i < givenArgs . length ; i ++ ) {
50
+ const a = givenArgs [ i ]
51
+ const argName = a . replace ( / ^ - + / , '' ) // "--foo" => "foo"
41
52
if ( ! validOptions . includes ( a ) ) {
42
53
throw Error ( `invalid argument: ${ a } ` )
43
54
}
55
+ if ( expectValue . includes ( a ) ) {
56
+ i ++
57
+ const val = givenArgs [ i ]
58
+ if ( val === undefined ) {
59
+ throw Error ( `missing value for arg: ${ a } ` )
60
+ }
61
+ args [ argName ] = val
62
+ } else {
63
+ args [ argName ] = true
64
+ }
44
65
}
45
66
46
- return {
47
- /** Produce an unoptimized VSIX. Include git SHA in version string. */
48
- debug : givenArgs . includes ( '--debug' ) ,
49
- /** Skips `npm run clean` when building the VSIX. This prevents file watching from breaking. */
50
- skipClean : givenArgs . includes ( '--no-clean' ) ,
51
- }
67
+ return args
52
68
}
53
69
54
70
/**
@@ -73,15 +89,15 @@ function isBeta(): boolean {
73
89
*
74
90
* @returns version-string suffix, for example: "-e6ecd84685a9"
75
91
*/
76
- function getVersionSuffix ( ) : string {
92
+ function getVersionSuffix ( feature : string ) : string {
77
93
if ( isRelease ( ) ) {
78
94
return ''
79
95
}
80
96
const commitId = child_process . execSync ( 'git rev-parse --short=12 HEAD' ) . toString ( ) . trim ( )
81
97
if ( ! commitId ) {
82
98
return ''
83
99
}
84
- return `-${ commitId } `
100
+ return `${ feature === '' ? '' : `- ${ feature } ` } -${ commitId } `
85
101
}
86
102
87
103
function main ( ) {
@@ -101,7 +117,7 @@ function main() {
101
117
fs . copyFileSync ( webpackConfigJsFile , `${ webpackConfigJsFile } .bk` )
102
118
103
119
const packageJson : typeof manifest = JSON . parse ( fs . readFileSync ( packageJsonFile , { encoding : 'utf-8' } ) )
104
- const versionSuffix = getVersionSuffix ( )
120
+ const versionSuffix = getVersionSuffix ( args . feature )
105
121
const version = packageJson . version
106
122
// Setting the version to an arbitrarily high number stops VSC from auto-updating the beta extension
107
123
const betaOrDebugVersion = `1.999.0${ versionSuffix } `
0 commit comments