Skip to content

Commit

Permalink
0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
suchipi committed Aug 12, 2022
1 parent 660eadf commit 90ba397
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 11 deletions.
Binary file added bin/darwin-arm/yavascript
Binary file not shown.
Binary file modified bin/darwin/yavascript
Binary file not shown.
Binary file modified bin/linux/yavascript
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yavascript",
"version": "0.0.2",
"version": "0.0.3",
"main": "lib/index.js",
"bin": "lib/cli.js",
"types": "yavascript.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yavascript",
"version": "0.0.2",
"version": "0.0.3",
"main": "dist/index.js",
"author": "Lily Scott <me@suchipi.com>",
"license": "MIT",
Expand Down
33 changes: 26 additions & 7 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ function makePath(...parts: Array<string | { separator: string }>) {

let resultingString = stringParts
.map((part) => {
return part.replace(new RegExp("\\" + wrongSeparator + "+", "g"), separator);
return part.replace(
new RegExp("\\" + wrongSeparator + "+", "g"),
separator
);
})
.join(separator);

Expand Down Expand Up @@ -413,25 +416,37 @@ function repoRoot(relativeTo: string = pwd()): string {
}

try {
const gitRootRun = exec(["git", "rev-parse", "--show-toplevel"], { captureOutput: true, failOnNonZeroStatus: false, cwd: relativeTo });
const gitRootRun = exec(["git", "rev-parse", "--show-toplevel"], {
captureOutput: true,
failOnNonZeroStatus: false,
cwd: relativeTo,
});
if (gitRootRun.status === 0) {
return gitRootRun.stdout.trim();
}
} catch (err) {}

try {
const hgRootRun = exec(["hg", "root"], { captureOutput: true, failOnNonZeroStatus: false, cwd: relativeTo });
const hgRootRun = exec(["hg", "root"], {
captureOutput: true,
failOnNonZeroStatus: false,
cwd: relativeTo,
});
if (hgRootRun.status === 0) {
return hgRootRun.stdout.trim();
}
} catch (err) {}


throw new Error(`Fatal: ${relativeTo} is not within a git or hg repo, or git/hg were not found in PATH`);
throw new Error(
`Fatal: ${relativeTo} is not within a git or hg repo, or git/hg were not found in PATH`
);
}

function isGitignored(path: string): boolean {
const result = exec(["git", "check-ignore", path], { failOnNonZeroStatus: false, captureOutput: true });
const result = exec(["git", "check-ignore", path], {
failOnNonZeroStatus: false,
captureOutput: true,
});
if (result.status !== 0 && result.status !== 1) {
throw new Error("git check-ignore failed: " + result.stderr.trim());
}
Expand All @@ -443,7 +458,11 @@ const baseApi = {
cd,
pwd,
realpath: os.realpath.bind(os),
readlink: os.readlink.bind(os),
readlink: os.readlink
? os.readlink.bind(os)
: () => {
throw new Error(`readlink is not yet supported in ${os.platform}`);
},
ls,
dirname,

Expand Down

0 comments on commit 90ba397

Please sign in to comment.