Skip to content

Commit

Permalink
fix: add support for typescript 2.6 (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofrobots authored Nov 3, 2017
1 parent daaa1a6 commit 7b3db0f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"author": "Google Inc.",
"license": "Apache-2.0",
"dependencies": {
"chalk": "^2.2.0",
"chalk": "^2.3.0",
"clang-format": "^1.0.53",
"inquirer": "^3.2.1",
"meow": "^3.7.0",
Expand All @@ -54,7 +54,7 @@
"@types/make-dir": "^1.0.1",
"@types/meow": "^3.6.2",
"@types/ncp": "^2.0.0",
"@types/node": "^8.0.17",
"@types/node": "^8.0.47",
"@types/pify": "3.0.0",
"@types/rimraf": "2.0.2",
"@types/tmp": "0.0.33",
Expand All @@ -66,7 +66,7 @@
"nyc": "^11.2.1",
"source-map-support": "^0.5.0",
"tmp": "0.0.31",
"typescript": "~2.4.1"
"typescript": "~2.6.1"
},
"peerDependencies": {
"typescript": "^2.4.1"
Expand Down
19 changes: 17 additions & 2 deletions test/test-kitchen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,33 @@ const simpleExecp = pify(cp.exec);
const renamep = pify(fs.rename);
const ncpp = pify(ncp.ncp);

// TODO: improve the typedefinitions in @types/node. Right now they specify
// the return type to be Error.
interface ExecError extends Error {
code: number;
}

function isExecError(err: Error|ExecError): err is ExecError {
return (<ExecError>err).code !== undefined;
}

// cp.exec doesn't fit the (err ^ result) pattern because a process can write
// to stdout/stderr and still exit with error code != 0.
// In most cases simply promisifying cp.exec is adequate, but it's not if we
// need to see console output for a process that exited with a non-zero exit
// code, so we define a more exhaustive promsified cp.exec here.
// TODO: replace this code with a npm modules that promisifies exec.
const execp =
(command: string, execOptions?: cp.ExecOptions): Promise<ExecResult> => {
return new Promise((resolve) => {
cp.exec(
command, execOptions || {},
(err: Error&{code: number}, stdout, stderr) => {
resolve({exitCode: err ? err.code : 0, stdout, stderr});
(err: Error|ExecError|null, stdout, stderr) => {
resolve({
exitCode: err && isExecError(err) ? err.code : 0,
stdout,
stderr
});
});
});
};
Expand Down

0 comments on commit 7b3db0f

Please # to comment.