Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
ShMcK merged 11 commits intomasterfromfeature/validate
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletionspackage-lock.json
View file
Open in desktop

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

2 changes: 2 additions & 0 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,6 +49,7 @@
"dependencies": {
"ajv": "^6.12.2",
"esm": "^3.2.25",
"fs-extra": "^9.0.1",
"js-yaml": "^3.14.0",
"kleur": "^3.0.3",
"lodash": "^4.17.15",
Expand All@@ -58,6 +59,7 @@
"devDependencies": {
"@babel/preset-typescript": "^7.10.1",
"@types/ajv": "^1.0.0",
"@types/fs-extra": "^9.0.1",
"@types/inquirer": "^6.5.0",
"@types/jest": "^25.2.3",
"@types/js-yaml": "^3.12.4",
Expand Down
91 changes: 91 additions & 0 deletionssrc/utils/exec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff 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 });
}
};
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp