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

Fixes#13

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 4 commits intomasterfromfixes
May 31, 2020
Merged
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
improve build error handling
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
@ShMcK
ShMcK committedMay 31, 2020
commit60c48ed739373f5044f41b69226a9f2e7c6b020d
69 changes: 54 additions & 15 deletionssrc/build.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,33 +46,72 @@ const parseArgs = (args: string[]): BuildArgs => {
};

async function build(args: string[]) {
const options = parseArgs(args);
let options: BuildArgs;
try {
options = parseArgs(args);
} catch (e) {
console.error("Error parsing build logs");
console.error(e.message);
return;
}

// path to run build from
const localPath = path.join(process.cwd(), options.dir);

// load files
const [_markdown, _yaml] = await Promise.all([
read(path.join(localPath, options.markdown), "utf8"),
read(path.join(localPath, options.yaml), "utf8"),
]);
let _markdown: string;
let _yaml: string;
try {
[_markdown, _yaml] = await Promise.all([
read(path.join(localPath, options.markdown), "utf8"),
read(path.join(localPath, options.yaml), "utf8"),
]);
} catch (e) {
console.error("Error reading file:");
console.error(e.message);
return;
}

const config = yamlParser.load(_yaml);
let config;
try {
config = yamlParser.load(_yaml);
} catch (e) {
console.error("Error parsing yaml");
console.error(e.message);
}

const commits: CommitLogObject = await getCommits(config.config.repo.branch);
let commits: CommitLogObject;
try {
commits = await getCommits({
localDir: localPath,
codeBranch: config.config.repo.branch,
});
} catch (e) {
console.error("Error loading commits:");
console.error(e.message);
return;
}

// Otherwise, continue with the other options
const tutorial: T.Tutorial = await parse({
text: _markdown,
config,
commits,
});
let tutorial: T.Tutorial;
try {
tutorial = await parse({
text: _markdown,
config,
commits,
});
} catch (e) {
console.error("Error parsing tutorial:");
console.error(e.message);
return;
}

if (tutorial) {
if (options.output) {
try {
await write(options.output, JSON.stringify(tutorial), "utf8");
} else {
console.log(JSON.stringify(tutorial, null, 2));
} catch (e) {
console.error("Error writing tutorial json:");
console.error(e.message);
}
}
}
Expand Down
16 changes: 16 additions & 0 deletionssrc/utils/commits.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,12 +37,26 @@ export async function getCommits({
const tempGit = gitP(tmpDir);
await tempGit.clone(localDir, tmpDir);

const branches = await git.branch();

if (!branches.all.length) {
throw new Error("No branches found");
} else if (!branches.all.includes(codeBranch)) {
throw new Error(`Code branch "${codeBranch}" not found`);
}

console.log("branches", branches);

// Checkout the code branches
await git.checkout(codeBranch);

console.log("checked out");

// Load all logs
const logs = await git.log();

console.log("logs", logs);

// Filter relevant logs
const commits: CommitLogObject = {};

Expand All@@ -63,6 +77,8 @@ export async function getCommits({
}
}
}

console.log("remove");
// cleanup the tmp directory
await rmdir(tmpDir, { recursive: true });
return commits;
Expand Down
4 changes: 2 additions & 2 deletionstests/parse.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,9 +5,9 @@ describe("parse", () => {
it("should parse summary", () => {
const md = `# Insert Tutorial's Title here

Short description to be shown as a tutorial's subtitle.
Short description to be shown as a tutorial's subtitle.

`;
`;

const config = { version: "0.1.0" };
const result = parse({
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp