Skip to content

Commit

Permalink
fix: error -> ETXTBSY: text file is busy
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo committed Nov 3, 2022
1 parent 0187a3e commit 814e0dd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/x6-build-tools/bin/rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ const script = scripts[event]

if (script) {
const tmpdir = os.tmpdir()
const dir = path.join(tmpdir, 'scripty')
const dir = path.join(tmpdir, 'rss')
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}
const hash = new Date().getTime()
const name = event.toLowerCase().replace(/[^0-9a-z]/g, '-')
const ext = isWin32 ? '.cmd' : ''
const file = path.join(dir, name, ext)
const file = path.join(dir, `${name}-${hash}`, ext)
const define = isWin32 ? '@ECHO OFF' : '#!/usr/bin/env sh'
const args = process.argv.slice(2)
const main = args.length ? `${script} ${args.join(' ')}` : script
Expand All @@ -42,7 +43,11 @@ if (script) {
])
const eventTitle = colors[eventColor](`[${event}]`)
console.log(`> ${eventTitle} ${main}`)
spawn(file, { stdio: 'inherit' })
const child = spawn(file, { stdio: 'inherit' })

child.on('exit', () => {
fs.rmSync(file)
})
} else {
console.error(`unknown script: [${event}]`)
}

0 comments on commit 814e0dd

Please sign in to comment.