Skip to content

Commit

Permalink
Make a nicer error handler for the case where users don't have the cl…
Browse files Browse the repository at this point in the history
…i installed (dataform-co#1130)

* Make a nicer error handler for the case where users don't have the cli installed

* Better messages

* No no-console

* Apparently the previous version was wrong
  • Loading branch information
George McGowan authored Nov 27, 2020
1 parent bd1a35b commit 6fbfbd2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vscode/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## This extension is in Alpha

To run this extension you will need the dataform cli installed globally: `npm i -g @dataform/cli`.
**To run this extension you will need the dataform cli installed globally: `npm i -g @dataform/cli`.**

Includes:

Expand Down
2 changes: 1 addition & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": "Syntax highlighting, compilation, and intellisense for Dataform and SQLX projects.",
"displayName": "Dataform",
"publisher": "dataform",
"version": "0.0.9",
"version": "0.0.11",
"icon": "dataform_logo.png",
"repository": {
"url": "https://github.com/dataform-co/dataform/tree/master/vscode"
Expand Down
8 changes: 8 additions & 0 deletions vscode/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ documents.onDidSave(change => {

async function compileAndValidate() {
const spawnedProcess = spawn("dataform", ["compile", "--json"]);
spawnedProcess.on("error", err => {
// tslint:disable-next-line: no-console
console.error("Error running 'dataform compile':", err);
connection.sendNotification(
"error",
"Errors encountered when running 'dataform' CLI. Please ensure that the CLI is installed and up-to-date: 'npm i -g @dataform/cli'."
);
});
const compileResult = await getProcessResult(spawnedProcess);

const parsedResult: dataform.ICompiledGraph = JSON.parse(compileResult.stdout);
Expand Down

0 comments on commit 6fbfbd2

Please sign in to comment.