fixed watch
This commit is contained in:
39
src/main.ts
39
src/main.ts
@@ -1,12 +1,6 @@
|
||||
import {
|
||||
existsSync,
|
||||
lstatSync,
|
||||
readdirSync,
|
||||
unlinkSync,
|
||||
writeFileSync,
|
||||
} from 'fs'
|
||||
import { existsSync, lstatSync, readdirSync, unlinkSync } from 'fs'
|
||||
import commandLineArgs from 'command-line-args'
|
||||
import { DistBase, DistPath, ScriptBase, ScriptPath } from './paths'
|
||||
import { DistBase, ScriptBase, ScriptPath } from './paths'
|
||||
import { readmeData, updateReadmeFile } from './readmefile'
|
||||
import runBuild from './build'
|
||||
import { UserScriptMetaFull } from './types'
|
||||
@@ -47,12 +41,8 @@ readdirSync(DistBase).forEach(file => unlinkSync(`${DistBase}/${file}`))
|
||||
meta: UserScriptMetaFull,
|
||||
error: string | null
|
||||
) {
|
||||
console.log('watch callback')
|
||||
scriptMeta[id] = { meta, error }
|
||||
doErrorFile(path.error, DistPath(name), error)
|
||||
|
||||
console.log('WATCH', name, meta.version)
|
||||
|
||||
updateReadmeFile(scriptMeta)
|
||||
}
|
||||
|
||||
@@ -63,29 +53,14 @@ readdirSync(DistBase).forEach(file => unlinkSync(`${DistBase}/${file}`))
|
||||
scriptMeta[id] = { meta, error }
|
||||
|
||||
console.log(name, meta.version)
|
||||
|
||||
doErrorFile(path.error, DistPath(name), error)
|
||||
}
|
||||
}
|
||||
|
||||
updateReadmeFile(scriptMeta)
|
||||
|
||||
console.log('\nFinished Compiling\n')
|
||||
if (CLIArgs.watch) console.log('Listening for Changes\n')
|
||||
console.log(
|
||||
`\nFinished Compiling\n${
|
||||
CLIArgs.watch ? 'Listening for Changes\n' : ''
|
||||
}`
|
||||
)
|
||||
})()
|
||||
|
||||
function doErrorFile(
|
||||
pathError: string,
|
||||
pathOutFile: string,
|
||||
error: string | null
|
||||
) {
|
||||
if (error !== null) {
|
||||
writeFileSync(pathError, `${new Date().toISOString()}\n\n${error}`)
|
||||
|
||||
if (existsSync(pathOutFile)) {
|
||||
unlinkSync(pathOutFile)
|
||||
}
|
||||
} else if (existsSync(pathError)) {
|
||||
unlinkSync(pathError)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user