shelljs > all. Added some gud logging and messages too. Creating temp dir works, as does the new binary checking

This commit is contained in:
Noah Santschi-Cooney 2018-05-13 18:27:38 +01:00
parent 36e22d0c3a
commit db563118c5
No known key found for this signature in database
GPG key ID: 3B22282472C8AE48
3 changed files with 84 additions and 71 deletions

114
package-lock.json generated
View file

@ -4,6 +4,29 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/events": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz",
"integrity": "sha512-KEIlhXnIutzKwRbQkGWb/I4HFqBuUykAdHgDED6xqwXJfONCjF5VoE0cXEiurh3XauygxzeDzgtXUqvLkxFzzA==",
"dev": true
},
"@types/glob": {
"version": "5.0.35",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-5.0.35.tgz",
"integrity": "sha512-wc+VveszMLyMWFvXLkloixT4n0harUIVZjnpzztaZ0nKLuul7Z32iMt2fUFGAaZ4y1XWjFRMtCI5ewvyh4aIeg==",
"dev": true,
"requires": {
"@types/events": "*",
"@types/minimatch": "*",
"@types/node": "*"
}
},
"@types/minimatch": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
"dev": true
},
"@types/mocha": {
"version": "2.2.48",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz",
@ -16,6 +39,16 @@
"integrity": "sha512-i8KiWTXKD8O76LjlTt+lK/8CUY/FDLbw5djHNrEK1SjOM6MAcZhvhskCX8vsujdxVD+UeX7SvusEzchLY4UBYQ==",
"dev": true
},
"@types/shelljs": {
"version": "0.7.9",
"resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.7.9.tgz",
"integrity": "sha512-GwfXBWx+JgH+mrf35NnNFPFl6kQZgDQqZBUdWrHB1phulBbVpOwedZun7hZRyfTOxlicwo4ftsC1fpUZZIiN5w==",
"dev": true,
"requires": {
"@types/glob": "*",
"@types/node": "*"
}
},
"ajv": {
"version": "5.5.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
@ -202,8 +235,7 @@
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"bcrypt-pbkdf": {
"version": "1.0.1",
@ -243,7 +275,6 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -395,8 +426,7 @@
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"convert-source-map": {
"version": "1.5.1",
@ -410,16 +440,6 @@
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
"dev": true
},
"create-symlink": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/create-symlink/-/create-symlink-1.0.0.tgz",
"integrity": "sha1-QNOKcRdnMiNFdi+Q+NBs8nJiAdc=",
"requires": {
"graceful-fs": "^4.1.11",
"inspect-with-kind": "^1.0.0",
"is-plain-obj": "^1.1.0"
}
},
"cryptiles": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz",
@ -744,8 +764,7 @@
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"fstream": {
"version": "1.0.11",
@ -772,7 +791,6 @@
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -905,7 +923,8 @@
"graceful-fs": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
"dev": true
},
"growl": {
"version": "1.10.3",
@ -1301,7 +1320,6 @@
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
@ -1310,23 +1328,12 @@
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"inspect-with-kind": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/inspect-with-kind/-/inspect-with-kind-1.0.4.tgz",
"integrity": "sha512-KN8VFSf62Ig4hyXtXODkWF6PIatrCIJF32KY8tQUwwLtgfNsr+3ZIpd+epM+pRbC86nJZycBPjWwziDvn/+6YQ==",
"requires": {
"kind-of": "^6.0.2"
},
"dependencies": {
"kind-of": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA=="
}
}
"interpret": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz",
"integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ="
},
"is": {
"version": "3.2.1",
@ -1402,11 +1409,6 @@
"integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=",
"dev": true
},
"is-plain-obj": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
"integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4="
},
"is-posix-bracket": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz",
@ -1768,7 +1770,6 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -1906,7 +1907,6 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": {
"wrappy": "1"
}
@ -1959,14 +1959,12 @@
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"path-parse": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz",
"integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=",
"dev": true
"integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME="
},
"pause-stream": {
"version": "0.0.11",
@ -2081,6 +2079,14 @@
"util-deprecate": "~1.0.1"
}
},
"rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
"requires": {
"resolve": "^1.1.6"
}
},
"regex-cache": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz",
@ -2154,7 +2160,6 @@
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz",
"integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==",
"dev": true,
"requires": {
"path-parse": "^1.0.5"
}
@ -2180,6 +2185,16 @@
"integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==",
"dev": true
},
"shelljs": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.2.tgz",
"integrity": "sha512-pRXeNrCA2Wd9itwhvLp5LZQvPJ0wU6bcjaTMywHHGX5XWhVN2nzSu7WV0q+oUY7mGK3mgSkDDzP3MgjqdyIgbQ==",
"requires": {
"glob": "^7.0.0",
"interpret": "^1.0.0",
"rechoir": "^0.6.2"
}
},
"sntp": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz",
@ -2600,8 +2615,7 @@
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"xtend": {
"version": "4.0.1",

View file

@ -29,6 +29,7 @@
"extensions": [
".fsh",
".vsh",
".gsh",
".glsl"
]
}
@ -54,12 +55,12 @@
"devDependencies": {
"@types/mocha": "^2.2.42",
"@types/node": "^7.0.43",
"@types/create-symlink": "./node_modules/@types/create-symlink",
"@types/shelljs": "^0.7.9",
"tslint": "^5.8.0",
"typescript": "^2.6.1",
"vscode": "^1.1.6"
},
"dependencies": {
"create-symlink": "^1.0.0"
"shelljs": "^0.8.2"
}
}

View file

@ -3,8 +3,8 @@
import * as vscode from 'vscode'
import * as os from 'os'
import * as cp from 'child_process'
import * as sym from 'create-symlink'
import * as fs from 'fs'
import * as shell from 'shelljs'
interface config {
glslangPath: string
@ -22,6 +22,14 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
this.config = this.initConfig()
this.checkBinary()
try {
shell.mkdir('-p', `${this.config.tmpdir}/shaders`)
console.log('[MC-GLSL] Successfully made temp directory', `${this.config.tmpdir}/shaders`)
} catch(e) {
console.error('[MC-GLSL] Error creating temp dir', e)
vscode.window.showErrorMessage('[MC-GLSL] Error creat ing temp directory. Check developer tools for more info.')
}
vscode.workspace.onDidOpenTextDocument(this.lint, this)
vscode.workspace.onDidSaveTextDocument(this.lint, this)
@ -37,27 +45,25 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
private initConfig(): config {
const c = vscode.workspace.getConfiguration('mcglsl')
console.log('glslangValidatorPath set to', c.get('glslangValidatorPath'))
console.log('temp dir set to', os.tmpdir())
console.log('[MC-GLSL] glslangValidatorPath set to', c.get('glslangValidatorPath'))
console.log('[MC-GLSL] temp directory root set to', `${os.tmpdir()}/${vscode.workspace.name}`)
return {
glslangPath: c.get('glslangValidatorPath') as string,
tmpdir: os.tmpdir()
tmpdir: `${os.tmpdir()}/${vscode.workspace.name}`
}
}
private checkBinary() {
var isWin = require('os').platform().indexOf('win') > -1;
let ret = shell.which(this.config.glslangPath)
var out = cp.execSync(`${isWin ? 'where' : 'whereis'} ${this.config.glslangPath}`);
if (out.toString().split(' ')[1] == null) {
if (ret == null) {
vscode.window.showErrorMessage(
'glslangValidator not found. Please check that you\'ve given the right path.' +
'[MC-GLSL] glslangValidator not found. Please check that you\'ve given the right path.' +
' Use the config option "mcglsl.glslangValidatorPath" to point to its location'
)
} else {
vscode.window.showInformationMessage('glslangValidator found!')
vscode.window.showInformationMessage('[MC-GLSL] glslangValidator found!')
}
}
@ -68,7 +74,7 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
private configChange(e: vscode.ConfigurationChangeEvent) {
if (e.affectsConfiguration('mcglsl')) {
console.log('config changed')
console.log('[MC-GLSL] config changed')
this.config = this.initConfig()
this.checkBinary()
}
@ -82,14 +88,6 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
if(document.languageId !== 'glsl') {
return
}
/* let diags: vscode.Diagnostic[] = []
let diag = new vscode.Diagnostic(new vscode.Range(11, 0, 11, 0), 'stuff n things', vscode.DiagnosticSeverity.Error)
diags.push(diag)
this.diagnosticCollection.set(document.uri, diags) */
/* fs.mkdirSync(`${this.config.tmpdir}/shaders`)
sym(`${vscode.workspace.rootPath}/shaders/composite.frag`, `${this.config.tmpdir}/shaders/composite.banana`)
.catch((err) => {console.log(err)}) */
}
public provideCodeActions(document: vscode.TextDocument,