Skip to content

Commit 506d997

Browse files
authored
fix: failed because directory already existed (#1772)
* fix: failed because directory already existed * fix: stderr is null
1 parent 764cca5 commit 506d997

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/GenHubot.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ function runCommands (hubotDirectory, options) {
66
options.hubotInstallationPath = options?.hubotInstallationPath ?? 'hubot'
77
console.log('creating hubot directory', hubotDirectory)
88
try {
9-
spawnSync('mkdir', [hubotDirectory], { shell: true, stdio: 'inherit' })
9+
File.mkdirSync(hubotDirectory, { recursive: true })
1010
} catch (error) {
1111
console.log(`${hubotDirectory} exists, continuing to the next operation.`)
1212
}
1313
const envFilePath = path.resolve(process.cwd(), '.env')
1414
process.chdir(hubotDirectory)
1515

1616
let output = spawnSync('npm', ['init', '-y'], { shell: true, stdio: 'inherit' })
17-
console.log('npm init', output.stderr.toString())
17+
console.log('npm init', output.stderr?.toString() ?? '')
1818
if (options.hubotInstallationPath !== 'hubot') {
1919
output = spawnSync('npm', ['pack', `${options.hubotInstallationPath}`], { shell: true, stdio: 'inherit' })
20-
console.log('npm pack', output.stderr.toString(), output.stdout.toString())
20+
console.log('npm pack', output.stderr?.toString() ?? '', output.stdout?.toString() ?? '')
2121
const customHubotPackage = JSON.parse(File.readFileSync(`${options.hubotInstallationPath}/package.json`, 'utf8'))
2222
output = spawnSync('npm', ['i', `${customHubotPackage.name}-${customHubotPackage.version}.tgz`], { shell: true, stdio: 'inherit' })
23-
console.log(`npm i ${customHubotPackage.name}-${customHubotPackage.version}.tgz`, output.stderr.toString(), output.stdout.toString())
23+
console.log(`npm i ${customHubotPackage.name}-${customHubotPackage.version}.tgz`, output.stderr?.toString() ?? '', output.stdout?.toString() ?? '')
2424
} else {
2525
output = spawnSync('npm', ['i', 'hubot@latest'], { shell: true, stdio: 'inherit' })
2626
}
2727
output = spawnSync('npm', ['i', 'hubot-help@latest', 'hubot-rules@latest', 'hubot-diagnostics@latest'].concat([options.adapter]).filter(Boolean))
28-
console.log('npm i', output.stderr.toString(), output.stdout.toString())
28+
console.log('npm i', output.stderr?.toString() ?? '', output.stdout?.toString() ?? '')
2929

3030
File.mkdirSync(path.join('tests', 'doubles'), { recursive: true })
3131

0 commit comments

Comments
 (0)