Skip to content

Commit

Permalink
fix(can-i-deploy): Can-i-deploy now prints a warning instead of faili…
Browse files Browse the repository at this point in the history
…ng if additional output is produced alongside the json
  • Loading branch information
TimothyJones committed Jan 29, 2021
1 parent 814d4fb commit 364afb2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
19 changes: 18 additions & 1 deletion src/can-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,24 @@ export class CanDeploy {

if (this.options.output === 'json') {
try {
const parsed = JSON.parse(result) as CanDeployResponse;
const startIndex = output.findIndex((l: string | Buffer) =>
l.toString().startsWith('{'),
);
if (startIndex === -1) {
logger.error(`can-i-deploy produced no json output:\n${result}`);
return deferred.reject(new Error(result));
}
if (startIndex !== 0) {
logger.warn(
`can-i-deploy produced additional output: \n${output.slice(
0,
startIndex,
)}`,
);
}
const jsonPart = output.slice(startIndex).join('\n');

const parsed = JSON.parse(jsonPart) as CanDeployResponse;
if (code === 0 && parsed.summary.deployable) {
return deferred.resolve(parsed);
}
Expand Down
16 changes: 4 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [
"es5",
"dom",
"es2015.promise"
],
"target": "es6",
"lib": ["es6", "dom"],
"removeComments": true,
"noLib": false,
"sourceMap": true,
Expand All @@ -21,11 +17,7 @@
"strict": true,
"noUnusedLocals": true
},
"include": [
"**/*.ts"
],
"exclude": [
"node_modules"
],
"include": ["**/*.ts"],
"exclude": ["node_modules"],
"compileOnSave": false
}

0 comments on commit 364afb2

Please sign in to comment.