- Notifications
You must be signed in to change notification settings - Fork2
Feature/validate#34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
11 commits Select commitHold shift + click to select a range
5b1a6dd
validate progress
ShMcK40a57fb
switch to fs-extra in validate
ShMcK55c4dcb
cherry-pick init commits
ShMcKb7acb67
run setup commands
ShMcK37b3d50
load step commits/commands
ShMcK9df45b1
test runner progress
ShMcK6f1c7ff
load solution commits
ShMcK514b2ad
prepare for test runner tests
ShMcK16e42f1
working solution test runner
ShMcKabd46f1
add setup tests
ShMcK2fc1113
cleanup output text ui
ShMcKFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
44 changes: 41 additions & 3 deletionspackage-lock.json
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
2 changes: 2 additions & 0 deletionspackage.json
This file contains hidden or 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
91 changes: 91 additions & 0 deletionssrc/utils/exec.ts
This file contains hidden or 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,91 @@ | ||
import * as T from "../../typings/tutorial"; | ||
import { exec as cpExec } from "child_process"; | ||
import * as path from "path"; | ||
import { promisify } from "util"; | ||
const asyncExec = promisify(cpExec); | ||
export function createExec(cwd: string) { | ||
return async function exec( | ||
command: string | ||
): Promise<{ stdout: string | null; stderr: string }> { | ||
try { | ||
const result = await asyncExec(command, { cwd }); | ||
return result; | ||
} catch (e) { | ||
return { stdout: null, stderr: e.message }; | ||
} | ||
}; | ||
} | ||
export function createCherryPick(cwd: string) { | ||
return async function cherryPick(commits: string[]): Promise<void> { | ||
for (const commit of commits) { | ||
try { | ||
const { stdout } = await createExec(cwd)( | ||
`git cherry-pick -X theirs ${commit}` | ||
); | ||
if (!stdout) { | ||
console.warn(`No cherry-pick output for ${commit}`); | ||
} | ||
} catch (e) { | ||
console.warn(`Cherry-pick failed for ${commit}`); | ||
} | ||
} | ||
}; | ||
} | ||
export function createCommandRunner(cwd: string) { | ||
return async function runCommands( | ||
commands: string[], | ||
dir?: string | ||
): Promise<boolean> { | ||
let errors = []; | ||
for (const command of commands) { | ||
try { | ||
console.log(`--> ${command}`); | ||
let cwdDir = cwd; | ||
if (dir) { | ||
cwdDir = path.join(cwd, dir); | ||
} | ||
const { stdout, stderr } = await createExec(cwdDir)(command); | ||
console.warn(stderr); | ||
} catch (e) { | ||
console.error(`Command failed: "${command}"`); | ||
console.warn(e.message); | ||
errors.push(e.message); | ||
} | ||
} | ||
return !!errors.length; | ||
}; | ||
} | ||
// function isAbsolute(p: string) { | ||
// return path.normalize(p + "/") === path.normalize(path.resolve(p) + "/"); | ||
// } | ||
export function createTestRunner(cwd: string, config: T.TestRunnerConfig) { | ||
const { command, args, directory } = config; | ||
// const commandIsAbsolute = isAbsolute(command); | ||
let wd = cwd; | ||
if (directory) { | ||
wd = path.join(cwd, directory); | ||
} | ||
const commandWithArgs = `${command} ${args.tap}`; | ||
return async function runTest(): Promise<{ | ||
stdout: string | null; | ||
stderr: string | null; | ||
}> { | ||
try { | ||
// console.log(await createExec(wd)("ls -a node_modules/.bin")); | ||
return await createExec(wd)(commandWithArgs); | ||
} catch (e) { | ||
return Promise.resolve({ stdout: null, stderr: e.message }); | ||
} | ||
}; | ||
} |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.