-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: convert core code to Typescript (no tests yes)
- Loading branch information
Showing
7 changed files
with
155 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ npm-debug.log | |
/.tox/ | ||
*.egg-info/ | ||
.venvs/ | ||
dist/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as childProcess from 'child_process'; | ||
|
||
function makeSpawnOptions(options) { | ||
const spawnOptions: childProcess.SpawnOptions = {shell: true}; | ||
if (options && options.cwd) { | ||
spawnOptions.cwd = options.cwd; | ||
} | ||
if (options && options.env) { | ||
spawnOptions.env = options.env; | ||
} | ||
return spawnOptions; | ||
} | ||
|
||
export function execute(command, args, options?): Promise<string> { | ||
const spawnOptions = makeSpawnOptions(options); | ||
|
||
return new Promise((resolve, reject) => { | ||
let stdout = ''; | ||
let stderr = ''; | ||
|
||
const proc = childProcess.spawn(command, args, spawnOptions); | ||
proc.stdout.on('data', (data) => { | ||
stdout = stdout + data; | ||
}); | ||
proc.stderr.on('data', (data) => { | ||
stderr = stderr + data; | ||
}); | ||
|
||
proc.on('close', (code) => { | ||
if (code !== 0) { | ||
return reject(stdout || stderr); | ||
} | ||
resolve(stdout || stderr); | ||
}); | ||
}); | ||
} | ||
|
||
export function executeSync(command, args, options?) { | ||
const spawnOptions = makeSpawnOptions(options); | ||
|
||
return childProcess.spawnSync(command, args, spawnOptions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "./dist", | ||
"pretty": true, | ||
"target": "es2015", | ||
"lib": [ | ||
"es2015", | ||
], | ||
"module": "commonjs", | ||
"allowJs": false, | ||
"sourceMap": true, | ||
"strict": true, | ||
"declaration": true, | ||
"importHelpers": true, | ||
"noImplicitAny": false // Needed to compile tap and ansi-escapes | ||
}, | ||
"include": [ | ||
"./lib/**/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "tslint:recommended", | ||
"rules": { | ||
"max-line-length": { | ||
"options": [120] | ||
}, | ||
"trailing-comma": [true, {"multiline": "always"}], | ||
"triple-equals": true, | ||
"curly": true, | ||
"indent": [true, "spaces", 2], | ||
"interface-name": false, | ||
"no-use-before-declare": true, | ||
"object-literal-sort-keys": false, | ||
"ordered-imports": false, | ||
"quotemark": [true, "single", "avoid-escape", "avoid-template"], | ||
"semicolon": [true, "always"], | ||
"no-console": [false] | ||
} | ||
} |