Delete temp files

This commit is contained in:
James-Yu 2017-03-27 14:03:21 +08:00
parent 1737f48e1e
commit 37d560365d
3 changed files with 15 additions and 1 deletions

View File

@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- (#39) LaTeX linting with `chktex`.
### Changed
- Web page title will show `[disconnected]` when the websocket is closed.
- Such web pages cannot communicate with the extension. Thus will not auto refresh or SyncTeX.
- Temp files created by log parser will be automatically deleted. In most cases.
## [1.0.2] - 2017-03-26
### Fixed
- (#38) Cope with typical language ids.

View File

@ -23,7 +23,7 @@ export class Linter {
if (this.currentProcess)
this.currentProcess.kill()
this.extension.logger.addLogMessage(`Linter start.`)
if (vscode.window.activeTextEditor.document.fileName === this.extension.manager.rootFile) {
if (vscode.window.activeTextEditor.document.fileName !== this.extension.manager.rootFile) {
let configuration = vscode.workspace.getConfiguration('latex-workshop')
let command = (configuration.get('linter_command') as string).replace('%DOC%', `"${this.extension.manager.rootFile}"`)
this.lintCommand(command, this.extension.manager.rootFile)
@ -48,6 +48,11 @@ export class Linter {
if (!error) {
this.extension.parser.parseLinter(stdout.split(fileName).join(this.extension.manager.rootFile))
this.extension.logger.addLogMessage(`Linter finished.`)
if (fileName !== this.extension.manager.rootFile) {
console.log(fileName)
fs.unlink(fileName)
this.extension.logger.addLogMessage(`Temp file removed: ${fileName}`)
}
return
}
this.extension.logger.addLogMessage(`Linter failed with error ${error.message}.`)

View File

@ -150,6 +150,10 @@ export class Parser {
diagsCollection[item.file].push(diag)
}
if (createBuildLogRaw) {
if (this.buildLogFile) {
fs.unlink(this.buildLogFile.name)
this.extension.logger.addLogMessage(`Temp file removed: ${this.buildLogFile.name}`)
}
this.buildLogFile = tmp.fileSync()
fs.writeFileSync(this.buildLogFile.fd, this.buildLogRaw)
}