Skip to content

Commit

Permalink
Fixes #42
Browse files Browse the repository at this point in the history
  • Loading branch information
zjhmale committed Mar 28, 2017
1 parent ec8b5cb commit ac6db38
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
18 changes: 17 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@
{
"command": "idris.send-selection-repl",
"group": "idris@13"
},
{
"command": "idris.cleanup-ibc",
"group": "idris@14"
}
]
},
Expand Down Expand Up @@ -222,6 +226,11 @@
"command": "idris.send-selection-repl",
"title": "Send selected code to REPL",
"description": "Send selected text to a refreshed REPL with currently opened file"
},
{
"command": "idris.cleanup-ibc",
"title": "Cleanup idris binary files",
"description": "Cleanup idris binary files"
}
],
"keybindings": [
Expand Down Expand Up @@ -314,6 +323,12 @@
"mac": "shift+cmd+x",
"when": "editorFocus && editorLangId == idris",
"command": "idris.send-selection-repl"
},
{
"key": "shift+ctrl+u",
"mac": "shift+cmd+u",
"when": "editorFocus && editorLangId == idris",
"command": "idris.cleanup-ibc"
}
],
"snippets": [
Expand All @@ -335,7 +350,8 @@
"cson": "4.0.0",
"eslint-plugin-promise": "3.5.0",
"request": "2.81.0",
"chalk": "1.1.3"
"chalk": "1.1.3",
"glob": "7.1.1"
},
"devDependencies": {
"vscode": "^1.0.5"
Expand Down
24 changes: 21 additions & 3 deletions src/controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
let ipkg = require('./ipkg/ipkg')
let commands = require('./idris/commands')
let vscode = require('vscode')
let glob = require("glob")
let fs = require('fs');

let getCommands = () => {
return [
Expand All @@ -18,15 +20,31 @@ let getCommands = () => {
['idris.apropos', runCommand(commands.apropos)],
['idris.eval-selection', runCommand(commands.evalSelection)],
['idris.start-refresh-repl', runCommand(commands.startREPL)],
['idris.send-selection-repl', runCommand(commands.sendREPL)]
['idris.send-selection-repl', runCommand(commands.sendREPL)],
['idris.cleanup-ibc', runCommand(cleanupIbc)]
]
}

let getCompilerOptsPromise = () => {
let getSafeRoot = () => {
let root = vscode.workspace.rootPath
let safeRoot = root === undefined ? "" : root
let compilerOptions = ipkg.compilerOptions(safeRoot)
return safeRoot
}

let cleanupIbc = (_) => {
glob(getSafeRoot() + "/**/*", (err, files) => {
if (!err) {
files.forEach((file) => {
if (file.endsWith(".ibc")) {
fs.unlinkSync(file)
}
})
}
})
}

let getCompilerOptsPromise = () => {
let compilerOptions = ipkg.compilerOptions(getSafeRoot())
return compilerOptions
}

Expand Down

0 comments on commit ac6db38

Please sign in to comment.