Skip to content

Commit 6a3e1ec

Browse files
committed
fixing path finding within the CLI
1 parent 497f4d9 commit 6a3e1ec

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
# TypeScript output
66
dist/
7-
*.js
7+
8+
**/snippets/
9+
810

911
# Logs
1012
logs

example/shnip.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const config = {
2+
rootDirectory: "./test",
3+
snippetOutputDirectory: "./snippets",
4+
fileExtensions: [".js", ".ts", ".kt", ".gradle", ".xml", ".bash", ".swift"],
5+
exclude: [],
6+
snippetTags: {
7+
start: ":snippet-start:",
8+
end: ":snippet-end:",
9+
prependStart: ":prepend-start:",
10+
prependEnd: ":prepend-end:",
11+
},
12+
outputDirectoryStructure: "byLanguage",
13+
version: "1.0.0",
14+
};

package/dist/bin/cli.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7752,10 +7752,9 @@ async function main() {
77527752
);
77537753
process.exit(1);
77547754
}
7755-
const projectRoot = path3.resolve(__dirname, "../../../");
7756-
config2.rootDirectory = path3.resolve(projectRoot, config2.rootDirectory);
7755+
config2.rootDirectory = path3.resolve(process.cwd(), config2.rootDirectory);
77577756
config2.snippetOutputDirectory = path3.resolve(
7758-
projectRoot,
7757+
process.cwd(),
77597758
config2.snippetOutputDirectory
77607759
);
77617760
if (args.includes("clear")) {

package/src/bin/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ async function main() {
2828
process.exit(1);
2929
}
3030

31-
const projectRoot = path.resolve(__dirname, "../../../");
32-
config.rootDirectory = path.resolve(projectRoot, config.rootDirectory);
31+
config.rootDirectory = path.resolve(process.cwd(), config.rootDirectory);
3332
config.snippetOutputDirectory = path.resolve(
34-
projectRoot,
33+
process.cwd(),
3534
config.snippetOutputDirectory
3635
);
3736

@@ -41,6 +40,7 @@ async function main() {
4140
return;
4241
}
4342

43+
// Handle the --structure flag
4444
const structureFlagIndex = args.indexOf("--structure");
4545
if (structureFlagIndex !== -1 && args.length > structureFlagIndex + 1) {
4646
const structureValue = args[structureFlagIndex + 1];

0 commit comments

Comments
 (0)