@@ -6,30 +6,34 @@ function runCommands (hubotDirectory, options) {
6
6
options . hubotInstallationPath = options ?. hubotInstallationPath ?? 'hubot'
7
7
console . log ( 'creating hubot directory' , hubotDirectory )
8
8
try {
9
- spawnSync ( 'mkdir' , [ hubotDirectory ] )
9
+ spawnSync ( 'mkdir' , [ hubotDirectory ] , { shell : true , stdio : 'inherit' } )
10
10
} catch ( error ) {
11
11
console . log ( `${ hubotDirectory } exists, continuing to the next operation.` )
12
12
}
13
13
const envFilePath = path . resolve ( process . cwd ( ) , '.env' )
14
14
process . chdir ( hubotDirectory )
15
15
16
- let output = spawnSync ( 'npm' , [ 'init' , '-y' ] )
16
+ let output = spawnSync ( 'npm' , [ 'init' , '-y' ] , { shell : true , stdio : 'inherit' } )
17
17
console . log ( 'npm init' , output . stderr . toString ( ) )
18
18
if ( options . hubotInstallationPath !== 'hubot' ) {
19
- output = spawnSync ( 'npm' , [ 'pack' , `${ options . hubotInstallationPath } ` ] )
19
+ output = spawnSync ( 'npm' , [ 'pack' , `${ options . hubotInstallationPath } ` ] , { shell : true , stdio : 'inherit' } )
20
20
console . log ( 'npm pack' , output . stderr . toString ( ) , output . stdout . toString ( ) )
21
21
const customHubotPackage = JSON . parse ( File . readFileSync ( `${ options . hubotInstallationPath } /package.json` , 'utf8' ) )
22
- output = spawnSync ( 'npm' , [ 'i' , `${ customHubotPackage . name } -${ customHubotPackage . version } .tgz` ] )
22
+ output = spawnSync ( 'npm' , [ 'i' , `${ customHubotPackage . name } -${ customHubotPackage . version } .tgz` ] , { shell : true , stdio : 'inherit' } )
23
23
console . log ( `npm i ${ customHubotPackage . name } -${ customHubotPackage . version } .tgz` , output . stderr . toString ( ) , output . stdout . toString ( ) )
24
24
} else {
25
- output = spawnSync ( 'npm' , [ 'i' , 'hubot@latest' ] )
25
+ output = spawnSync ( 'npm' , [ 'i' , 'hubot@latest' ] , { shell : true , stdio : 'inherit' } )
26
26
}
27
27
output = spawnSync ( 'npm' , [ 'i' , 'hubot-help@latest' , 'hubot-rules@latest' , 'hubot-diagnostics@latest' ] . concat ( [ options . adapter ] ) . filter ( Boolean ) )
28
28
console . log ( 'npm i' , output . stderr . toString ( ) , output . stdout . toString ( ) )
29
- spawnSync ( 'mkdir' , [ 'scripts' , 'tests' , 'tests/doubles' ] )
30
- spawnSync ( 'touch ', [ 'external-scripts.json' ] )
29
+
30
+ File . mkdirSync ( path . join ( 'tests ', 'doubles' ) , { recursive : true } )
31
31
32
32
const externalScriptsPath = path . resolve ( './' , 'external-scripts.json' )
33
+ if ( ! File . existsSync ( externalScriptsPath ) ) {
34
+ File . writeFileSync ( externalScriptsPath , '[]' )
35
+ }
36
+
33
37
let escripts = File . readFileSync ( externalScriptsPath , 'utf8' )
34
38
if ( escripts . length === 0 ) escripts = '[]'
35
39
const externalScripts = JSON . parse ( escripts )
@@ -39,6 +43,8 @@ function runCommands (hubotDirectory, options) {
39
43
40
44
File . writeFileSync ( externalScriptsPath , JSON . stringify ( externalScripts , null , 2 ) )
41
45
46
+ File . mkdirSync ( path . join ( 'scripts' ) , { recursive : true } )
47
+
42
48
File . writeFileSync ( './scripts/Xample.mjs' , `// Description:
43
49
// Test script
44
50
//
0 commit comments