yargs-file-commands 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/lib/fileCommands.js +11 -2
- package/package.json +1 -1
- package/src/lib/fileCommands.ts +18 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# yargs-file-commands
|
|
2
2
|
|
|
3
|
+
## 0.0.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- More explicit exceptions when bad parameters are passed in
|
|
8
|
+
- Validate that provided command directories are aboslute
|
|
9
|
+
- More robust parameter checking and logging
|
|
10
|
+
- Improved debugging logging
|
|
11
|
+
- More robust debug messages
|
|
12
|
+
|
|
3
13
|
## 0.0.12
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/lib/fileCommands.js
CHANGED
|
@@ -55,12 +55,21 @@ export const fileCommands = async (options) => {
|
|
|
55
55
|
if (fullOptions.commandDirs.length === 0) {
|
|
56
56
|
throw new Error('No command directories provided');
|
|
57
57
|
}
|
|
58
|
+
// throw if some command directories are not absolute, first filter to find non-absolute an then throw, listing those that are not absolute
|
|
59
|
+
const nonAbsoluteDirs = fullOptions.commandDirs.filter((dir) => !path.isAbsolute(dir));
|
|
60
|
+
if (nonAbsoluteDirs.length > 0) {
|
|
61
|
+
throw new Error(`Command directories must be absolute paths: ${nonAbsoluteDirs.join(', ')}`);
|
|
62
|
+
}
|
|
58
63
|
const commands = [];
|
|
59
64
|
for (const commandDir of fullOptions.commandDirs) {
|
|
60
65
|
const fullPath = path.resolve(commandDir);
|
|
61
|
-
|
|
66
|
+
if (fullOptions.logLevel === 'debug') {
|
|
67
|
+
console.debug(`Scanning directory for commands: ${fullPath}`);
|
|
68
|
+
}
|
|
62
69
|
const filePaths = await scanDirectory(commandDir, commandDir, fullOptions);
|
|
63
|
-
|
|
70
|
+
if (fullOptions.logLevel === 'debug') {
|
|
71
|
+
console.debug(`Importing found commands:`);
|
|
72
|
+
}
|
|
64
73
|
for (const filePath of filePaths) {
|
|
65
74
|
const localPath = path.relative(commandDir, filePath);
|
|
66
75
|
const segments = segmentPath(filePath, commandDir);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs-file-commands",
|
|
3
3
|
"description": "A yargs helper function that lets you define your commands structure via directory and file naming conventions.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.13",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
package/src/lib/fileCommands.ts
CHANGED
|
@@ -82,15 +82,31 @@ export const fileCommands = async (options: FileCommandsOptions) => {
|
|
|
82
82
|
throw new Error('No command directories provided');
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
// throw if some command directories are not absolute, first filter to find non-absolute an then throw, listing those that are not absolute
|
|
86
|
+
const nonAbsoluteDirs = fullOptions.commandDirs.filter(
|
|
87
|
+
(dir) => !path.isAbsolute(dir)
|
|
88
|
+
);
|
|
89
|
+
if (nonAbsoluteDirs.length > 0) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Command directories must be absolute paths: ${nonAbsoluteDirs.join(
|
|
92
|
+
', '
|
|
93
|
+
)}`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
85
97
|
const commands: Command[] = [];
|
|
86
98
|
|
|
87
99
|
for (const commandDir of fullOptions.commandDirs) {
|
|
88
100
|
const fullPath = path.resolve(commandDir);
|
|
89
|
-
|
|
101
|
+
if (fullOptions.logLevel === 'debug') {
|
|
102
|
+
console.debug(`Scanning directory for commands: ${fullPath}`);
|
|
103
|
+
}
|
|
90
104
|
|
|
91
105
|
const filePaths = await scanDirectory(commandDir, commandDir, fullOptions);
|
|
92
106
|
|
|
93
|
-
|
|
107
|
+
if (fullOptions.logLevel === 'debug') {
|
|
108
|
+
console.debug(`Importing found commands:`);
|
|
109
|
+
}
|
|
94
110
|
for (const filePath of filePaths) {
|
|
95
111
|
const localPath = path.relative(commandDir, filePath);
|
|
96
112
|
const segments = segmentPath(filePath, commandDir);
|