Skip to content

Commit

Permalink
Minor fix/clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
jad-hamza committed Mar 8, 2020
1 parent 0ddd643 commit afb89b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"fitcode.executableOptions": {
"type": "string",
"scope": "resource",
"default": "--no-info",
"default": "--no-info --no-colors",
"description": "Options passed to the Stainless Fit executable"
}
}
Expand Down
14 changes: 3 additions & 11 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ function fitCommand(fitCmd: string) {
if (editor) {
let document = editor.document
let path = document.fileName
//let filename = pathToFilename(path)

const cmd = `${fit()} ${fitCmd} ${options()} "${path}"`

run(cmd)
run(`${fit()} ${fitCmd} ${options()} "${path}"`)
}
}

Expand Down Expand Up @@ -112,7 +109,7 @@ function options() {
async function sh(cmd: string): Promise<string> {
return new Promise(function (resolve, reject) {
exec(cmd, (err, stdout, stderr) => {
if ( stdout.length == 0 || err) {
if (stdout.length == 0 || err) {
reject(new CommandReturn(stdout, stderr, err))
} else {
resolve(stdout)
Expand All @@ -129,7 +126,7 @@ function defaultOnSuccess(stdout: string): void {

function defaultOnFailure(cr:CommandReturn): void {
console.log(cr.toString)
window.showErrorMessage("Error occured, see output")
window.showErrorMessage("Error occurred, see output")
outputChannel.append(cr.toString())
}

Expand All @@ -154,11 +151,6 @@ function run(cmd: string, onSuccess = defaultOnSuccess, onFailure = defaultOnFai
return progress
}

function pathToFilename(path: string): string{
let regex = /([^/\\]*[/\\][/\\]*)*/ //leaves only filename
return path.replace(regex,"")
}

class CommandReturn{
constructor(readonly stdout: string, readonly stderr: string, readonly err?: ExecException | null){}

Expand Down

0 comments on commit afb89b5

Please sign in to comment.