shell-dsl 0.0.26 → 0.0.28
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/dist/cjs/index.cjs +24 -13
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/commands/awk/awk.cjs +19 -9
- package/dist/cjs/src/commands/awk/awk.cjs.map +2 -2
- package/dist/cjs/src/commands/break-continue/break-continue.cjs +19 -9
- package/dist/cjs/src/commands/break-continue/break-continue.cjs.map +2 -2
- package/dist/cjs/src/commands/cat/cat.cjs +19 -9
- package/dist/cjs/src/commands/cat/cat.cjs.map +2 -2
- package/dist/cjs/src/commands/cd/cd.cjs +19 -9
- package/dist/cjs/src/commands/cd/cd.cjs.map +2 -2
- package/dist/cjs/src/commands/colon/colon.cjs +19 -9
- package/dist/cjs/src/commands/colon/colon.cjs.map +2 -2
- package/dist/cjs/src/commands/cp/cp.cjs +19 -9
- package/dist/cjs/src/commands/cp/cp.cjs.map +2 -2
- package/dist/cjs/src/commands/cut/cut.cjs +19 -9
- package/dist/cjs/src/commands/cut/cut.cjs.map +2 -2
- package/dist/cjs/src/commands/echo/echo.cjs +19 -9
- package/dist/cjs/src/commands/echo/echo.cjs.map +2 -2
- package/dist/cjs/src/commands/find/find.cjs +21 -66
- package/dist/cjs/src/commands/find/find.cjs.map +3 -3
- package/dist/cjs/src/commands/grep/grep.cjs +22 -26
- package/dist/cjs/src/commands/grep/grep.cjs.map +3 -3
- package/dist/cjs/src/commands/head/head.cjs +19 -9
- package/dist/cjs/src/commands/head/head.cjs.map +2 -2
- package/dist/cjs/src/commands/index.cjs +19 -9
- package/dist/cjs/src/commands/index.cjs.map +2 -2
- package/dist/cjs/src/commands/ls/ls.cjs +19 -9
- package/dist/cjs/src/commands/ls/ls.cjs.map +2 -2
- package/dist/cjs/src/commands/mkdir/mkdir.cjs +19 -9
- package/dist/cjs/src/commands/mkdir/mkdir.cjs.map +2 -2
- package/dist/cjs/src/commands/mv/mv.cjs +19 -9
- package/dist/cjs/src/commands/mv/mv.cjs.map +2 -2
- package/dist/cjs/src/commands/pwd/pwd.cjs +19 -9
- package/dist/cjs/src/commands/pwd/pwd.cjs.map +2 -2
- package/dist/cjs/src/commands/rm/rm.cjs +19 -9
- package/dist/cjs/src/commands/rm/rm.cjs.map +2 -2
- package/dist/cjs/src/commands/sed/sed.cjs +19 -9
- package/dist/cjs/src/commands/sed/sed.cjs.map +2 -2
- package/dist/cjs/src/commands/sort/sort.cjs +19 -9
- package/dist/cjs/src/commands/sort/sort.cjs.map +2 -2
- package/dist/cjs/src/commands/tail/tail.cjs +19 -9
- package/dist/cjs/src/commands/tail/tail.cjs.map +2 -2
- package/dist/cjs/src/commands/tee/tee.cjs +19 -9
- package/dist/cjs/src/commands/tee/tee.cjs.map +2 -2
- package/dist/cjs/src/commands/test/test.cjs +19 -9
- package/dist/cjs/src/commands/test/test.cjs.map +2 -2
- package/dist/cjs/src/commands/touch/touch.cjs +19 -9
- package/dist/cjs/src/commands/touch/touch.cjs.map +2 -2
- package/dist/cjs/src/commands/tr/tr.cjs +19 -9
- package/dist/cjs/src/commands/tr/tr.cjs.map +2 -2
- package/dist/cjs/src/commands/tree/tree.cjs +33 -12
- package/dist/cjs/src/commands/tree/tree.cjs.map +3 -3
- package/dist/cjs/src/commands/true-false/true-false.cjs +19 -9
- package/dist/cjs/src/commands/true-false/true-false.cjs.map +2 -2
- package/dist/cjs/src/commands/uniq/uniq.cjs +19 -9
- package/dist/cjs/src/commands/uniq/uniq.cjs.map +2 -2
- package/dist/cjs/src/commands/wc/wc.cjs +19 -9
- package/dist/cjs/src/commands/wc/wc.cjs.map +2 -2
- package/dist/cjs/src/errors.cjs +19 -9
- package/dist/cjs/src/errors.cjs.map +2 -2
- package/dist/cjs/src/fs/index.cjs +19 -9
- package/dist/cjs/src/fs/index.cjs.map +2 -2
- package/dist/cjs/src/fs/memfs-adapter.cjs +31 -10
- package/dist/cjs/src/fs/memfs-adapter.cjs.map +2 -2
- package/dist/cjs/src/fs/readonly-fs.cjs +19 -9
- package/dist/cjs/src/fs/readonly-fs.cjs.map +2 -2
- package/dist/cjs/src/fs/real-fs.cjs +31 -10
- package/dist/cjs/src/fs/real-fs.cjs.map +2 -2
- package/dist/cjs/src/index.cjs +19 -9
- package/dist/cjs/src/index.cjs.map +2 -2
- package/dist/cjs/src/interpreter/context.cjs +19 -9
- package/dist/cjs/src/interpreter/context.cjs.map +2 -2
- package/dist/cjs/src/interpreter/index.cjs +19 -9
- package/dist/cjs/src/interpreter/index.cjs.map +2 -2
- package/dist/cjs/src/interpreter/interpreter.cjs +19 -9
- package/dist/cjs/src/interpreter/interpreter.cjs.map +2 -2
- package/dist/cjs/src/io/index.cjs +19 -9
- package/dist/cjs/src/io/index.cjs.map +2 -2
- package/dist/cjs/src/io/stdin.cjs +19 -9
- package/dist/cjs/src/io/stdin.cjs.map +2 -2
- package/dist/cjs/src/io/stdout.cjs +19 -9
- package/dist/cjs/src/io/stdout.cjs.map +2 -2
- package/dist/cjs/src/lexer/index.cjs +19 -9
- package/dist/cjs/src/lexer/index.cjs.map +2 -2
- package/dist/cjs/src/lexer/lexer.cjs +19 -9
- package/dist/cjs/src/lexer/lexer.cjs.map +2 -2
- package/dist/cjs/src/lexer/tokens.cjs +19 -9
- package/dist/cjs/src/lexer/tokens.cjs.map +2 -2
- package/dist/cjs/src/parser/ast.cjs +19 -9
- package/dist/cjs/src/parser/ast.cjs.map +2 -2
- package/dist/cjs/src/parser/index.cjs +19 -9
- package/dist/cjs/src/parser/index.cjs.map +2 -2
- package/dist/cjs/src/parser/parser.cjs +19 -9
- package/dist/cjs/src/parser/parser.cjs.map +2 -2
- package/dist/cjs/src/shell-dsl.cjs +19 -9
- package/dist/cjs/src/shell-dsl.cjs.map +2 -2
- package/dist/cjs/src/shell-promise.cjs +19 -9
- package/dist/cjs/src/shell-promise.cjs.map +2 -2
- package/dist/cjs/src/types.cjs +19 -9
- package/dist/cjs/src/types.cjs.map +2 -2
- package/dist/cjs/src/utils/escape.cjs +19 -9
- package/dist/cjs/src/utils/escape.cjs.map +2 -2
- package/dist/cjs/src/utils/expand-escapes.cjs +19 -9
- package/dist/cjs/src/utils/expand-escapes.cjs.map +2 -2
- package/dist/cjs/src/utils/flag-parser.cjs +27 -9
- package/dist/cjs/src/utils/flag-parser.cjs.map +3 -3
- package/dist/cjs/src/utils/index.cjs +21 -9
- package/dist/cjs/src/utils/index.cjs.map +3 -3
- package/dist/cjs/src/utils/match-glob.cjs +102 -0
- package/dist/cjs/src/utils/match-glob.cjs.map +10 -0
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/src/commands/find/find.mjs +2 -57
- package/dist/mjs/src/commands/find/find.mjs.map +3 -3
- package/dist/mjs/src/commands/grep/grep.mjs +4 -18
- package/dist/mjs/src/commands/grep/grep.mjs.map +3 -3
- package/dist/mjs/src/commands/tree/tree.mjs +15 -4
- package/dist/mjs/src/commands/tree/tree.mjs.map +3 -3
- package/dist/mjs/src/utils/flag-parser.mjs +9 -1
- package/dist/mjs/src/utils/flag-parser.mjs.map +3 -3
- package/dist/mjs/src/utils/index.mjs +3 -1
- package/dist/mjs/src/utils/index.mjs.map +3 -3
- package/dist/mjs/src/utils/match-glob.mjs +62 -0
- package/dist/mjs/src/utils/match-glob.mjs.map +10 -0
- package/dist/types/src/utils/index.d.ts +1 -0
- package/dist/types/src/utils/match-glob.d.ts +5 -0
- package/package.json +1 -1
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -107,4 +117,4 @@ var head = async (ctx) => {
|
|
|
107
117
|
return 0;
|
|
108
118
|
};
|
|
109
119
|
|
|
110
|
-
//# debugId=
|
|
120
|
+
//# debugId=F0828B92D284BE0A64756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\n\ninterface HeadFlags {\n lines: number;\n}\n\nconst spec = {\n name: \"head\",\n flags: [\n { short: \"n\", long: \"lines\", takesValue: true },\n ] as FlagDefinition[],\n usage: \"head [-n lines] [file ...]\",\n};\n\nconst defaults: HeadFlags = { lines: 10 };\n\nconst handler = (flags: HeadFlags, flag: FlagDefinition, value?: string) => {\n if (flag.short === \"n\" && value) {\n flags.lines = parseInt(value, 10);\n }\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\nexport const head: Command = async (ctx) => {\n // Pre-process args to handle legacy -N format (e.g., -5 means -n 5)\n const processedArgs: string[] = [];\n for (const arg of ctx.args) {\n if (arg.startsWith(\"-\") && /^-\\d+$/.test(arg)) {\n processedArgs.push(\"-n\", arg.slice(1));\n } else {\n processedArgs.push(arg);\n }\n }\n\n const result = parser.parse(processedArgs);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n const numLines = result.flags.lines;\n const files = result.args;\n\n if (isNaN(numLines) || numLines < 0) {\n await ctx.stderr.writeText(\"head: invalid number of lines\\n\");\n return 1;\n }\n\n const outputLines = async (content: string) => {\n const lines = content.split(\"\\n\");\n const toOutput = lines.slice(0, numLines);\n for (let i = 0; i < toOutput.length; i++) {\n await ctx.stdout.writeText(toOutput[i]!);\n if (i < toOutput.length - 1 || (lines.length > numLines)) {\n await ctx.stdout.writeText(\"\\n\");\n }\n }\n };\n\n if (files.length === 0) {\n // Read from stdin\n const content = await ctx.stdin.text();\n await outputLines(content);\n } else {\n for (let i = 0; i < files.length; i++) {\n const file = files[i]!;\n try {\n if (files.length > 1) {\n if (i > 0) await ctx.stdout.writeText(\"\\n\");\n await ctx.stdout.writeText(`==> ${file} <==\\n`);\n }\n const path = ctx.fs.resolve(ctx.cwd, file);\n const content = (await ctx.fs.readFile(path)).toString();\n await outputLines(content);\n } catch (err) {\n await ctx.stderr.writeText(`head: ${file}: No such file or directory\\n`);\n return 1;\n }\n }\n }\n\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;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I,EAAG,IAAI,SAAS,QAAQ,KAAK;AAAA,MACxC,MAAM,IAAI,OAAO,UAAU,SAAS,EAAG;AAAA,MACvC,IAAI,IAAI,SAAS,SAAS,KAAM,MAAM,SAAS,UAAW;AAAA,QACxD,MAAM,IAAI,OAAO,UAAU;AAAA,CAAI;AAAA,MACjC;AAAA,IACF;AAAA;AAAA,EAGF,IAAI,MAAM,WAAW,GAAG;AAAA,IAEtB,MAAM,UAAU,MAAM,IAAI,MAAM,KAAK;AAAA,IACrC,MAAM,YAAY,OAAO;AAAA,EAC3B,EAAO;AAAA,IACL,SAAS,IAAI,EAAG,IAAI,MAAM,QAAQ,KAAK;AAAA,MACrC,MAAM,OAAO,MAAM;AAAA,MACnB,IAAI;AAAA,QACF,IAAI,MAAM,SAAS,GAAG;AAAA,UACpB,IAAI,IAAI;AAAA,YAAG,MAAM,IAAI,OAAO,UAAU;AAAA,CAAI;AAAA,UAC1C,MAAM,IAAI,OAAO,UAAU,OAAO;AAAA,CAAY;AAAA,QAChD;AAAA,QACA,MAAM,OAAO,IAAI,GAAG,QAAQ,IAAI,KAAK,IAAI;AAAA,QACzC,MAAM,WAAW,MAAM,IAAI,GAAG,SAAS,IAAI,GAAG,SAAS;AAAA,QACvD,MAAM,YAAY,OAAO;AAAA,QACzB,OAAO,KAAK;AAAA,QACZ,MAAM,IAAI,OAAO,UAAU,SAAS;AAAA,CAAmC;AAAA,QACvE,OAAO;AAAA;AAAA,IAEX;AAAA;AAAA,EAGF,OAAO;AAAA;",
|
|
8
|
+
"debugId": "F0828B92D284BE0A64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -149,4 +159,4 @@ var builtinCommands = {
|
|
|
149
159
|
cut: import_cut2.cut
|
|
150
160
|
};
|
|
151
161
|
|
|
152
|
-
//# debugId=
|
|
162
|
+
//# debugId=245790BFC6ECB4BD64756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../types.cjs\";\n\nexport { echo } from \"./echo/echo.cjs\";\nexport { cat } from \"./cat/cat.cjs\";\nexport { grep } from \"./grep/grep.cjs\";\nexport { wc } from \"./wc/wc.cjs\";\nexport { head } from \"./head/head.cjs\";\nexport { tail } from \"./tail/tail.cjs\";\nexport { sort } from \"./sort/sort.cjs\";\nexport { uniq } from \"./uniq/uniq.cjs\";\nexport { pwd } from \"./pwd/pwd.cjs\";\nexport { ls } from \"./ls/ls.cjs\";\nexport { mkdir } from \"./mkdir/mkdir.cjs\";\nexport { rm } from \"./rm/rm.cjs\";\nexport { test, bracket } from \"./test/test.cjs\";\nexport { trueCmd, falseCmd } from \"./true-false/true-false.cjs\";\nexport { touch } from \"./touch/touch.cjs\";\nexport { cp } from \"./cp/cp.cjs\";\nexport { mv } from \"./mv/mv.cjs\";\nexport { tee } from \"./tee/tee.cjs\";\nexport { tree } from \"./tree/tree.cjs\";\nexport { find } from \"./find/find.cjs\";\nexport { sed } from \"./sed/sed.cjs\";\nexport { awk } from \"./awk/awk.cjs\";\nexport { breakCmd, continueCmd } from \"./break-continue/break-continue.cjs\";\nexport { colon } from \"./colon/colon.cjs\";\nexport { cd } from \"./cd/cd.cjs\";\nexport { tr } from \"./tr/tr.cjs\";\nexport { cut } from \"./cut/cut.cjs\";\n\n// Re-export all commands as a bundle\nimport { echo } from \"./echo/echo.cjs\";\nimport { cat } from \"./cat/cat.cjs\";\nimport { grep } from \"./grep/grep.cjs\";\nimport { wc } from \"./wc/wc.cjs\";\nimport { head } from \"./head/head.cjs\";\nimport { tail } from \"./tail/tail.cjs\";\nimport { sort } from \"./sort/sort.cjs\";\nimport { uniq } from \"./uniq/uniq.cjs\";\nimport { pwd } from \"./pwd/pwd.cjs\";\nimport { ls } from \"./ls/ls.cjs\";\nimport { mkdir } from \"./mkdir/mkdir.cjs\";\nimport { rm } from \"./rm/rm.cjs\";\nimport { test, bracket } from \"./test/test.cjs\";\nimport { trueCmd, falseCmd } from \"./true-false/true-false.cjs\";\nimport { touch } from \"./touch/touch.cjs\";\nimport { cp } from \"./cp/cp.cjs\";\nimport { mv } from \"./mv/mv.cjs\";\nimport { tee } from \"./tee/tee.cjs\";\nimport { tree } from \"./tree/tree.cjs\";\nimport { find } from \"./find/find.cjs\";\nimport { sed } from \"./sed/sed.cjs\";\nimport { awk } from \"./awk/awk.cjs\";\nimport { breakCmd, continueCmd } from \"./break-continue/break-continue.cjs\";\nimport { colon } from \"./colon/colon.cjs\";\nimport { cd } from \"./cd/cd.cjs\";\nimport { tr } from \"./tr/tr.cjs\";\nimport { cut } from \"./cut/cut.cjs\";\n\nexport const builtinCommands: Record<string, Command> = {\n echo,\n cat,\n grep,\n wc,\n head,\n tail,\n sort,\n uniq,\n pwd,\n ls,\n mkdir,\n rm,\n test,\n \"[\": bracket,\n true: trueCmd,\n false: falseCmd,\n touch,\n cp,\n mv,\n tee,\n tree,\n find,\n sed,\n awk,\n break: breakCmd,\n continue: continueCmd,\n \":\": colon,\n cd,\n tr,\n cut,\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEqB,IAArB;AACoB,IAApB;AACqB,IAArB;AACmB,IAAnB;AACqB,IAArB;AACqB,IAArB;AACqB,IAArB;AACqB,IAArB;AACoB,IAApB;AACmB,IAAnB;AACsB,IAAtB;AACmB,IAAnB;AAC8B,IAA9B;AACkC,IAAlC;AACsB,IAAtB;AACmB,IAAnB;AACmB,IAAnB;AACoB,IAApB;AACqB,IAArB;AACqB,IAArB;AACoB,IAApB;AACoB,IAApB;AACsC,IAAtC;AACsB,IAAtB;AACmB,IAAnB;AACmB,IAAnB;AACoB,IAApB;AAGqB,IAArB;AACoB,IAApB;AACqB,IAArB;AACmB,IAAnB;AACqB,IAArB;AACqB,IAArB;AACqB,IAArB;AACqB,IAArB;AACoB,IAApB;AACmB,IAAnB;AACsB,IAAtB;AACmB,IAAnB;AAC8B,IAA9B;AACkC,IAAlC;AACsB,IAAtB;AACmB,IAAnB;AACmB,IAAnB;AACoB,IAApB;AACqB,IAArB;AACqB,IAArB;AACoB,IAApB;AACoB,IAApB;AACsC,IAAtC;AACsB,IAAtB;AACmB,IAAnB;AACmB,IAAnB;AACoB,IAApB;AAEO,IAAM,kBAA2C;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,UAAU;AAAA,EACV,KAAK;AAAA,EACL;AAAA,EACA;AAAA,EACA;AACF;",
|
|
8
|
+
"debugId": "245790BFC6ECB4BD64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -191,4 +201,4 @@ var ls = async (ctx) => {
|
|
|
191
201
|
return 0;
|
|
192
202
|
};
|
|
193
203
|
|
|
194
|
-
//# debugId=
|
|
204
|
+
//# debugId=A23859FA1A3F678664756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\n\ninterface LsFlags {\n all: boolean;\n long: boolean;\n onePerLine: boolean;\n recursive: boolean;\n humanReadable: boolean;\n}\n\nconst spec = {\n name: \"ls\",\n flags: [\n { short: \"a\", long: \"all\" },\n { short: \"l\" },\n { short: \"h\" },\n { short: \"1\" },\n { short: \"R\" },\n ] as FlagDefinition[],\n usage: \"ls [-alhR1] [file ...]\",\n};\n\nconst defaults: LsFlags = { all: false, long: false, onePerLine: false, recursive: false, humanReadable: false };\n\nconst handler = (flags: LsFlags, flag: FlagDefinition) => {\n if (flag.short === \"a\") flags.all = true;\n if (flag.short === \"l\") flags.long = true;\n if (flag.short === \"h\") flags.humanReadable = true;\n if (flag.short === \"1\") flags.onePerLine = true;\n if (flag.short === \"R\") flags.recursive = true;\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\nconst BOLD_BLUE = \"\\x1b[1;34m\";\nconst RESET = \"\\x1b[0m\";\n\nfunction formatSize(bytes: number, humanReadable: boolean): string {\n if (!humanReadable) return String(bytes).padStart(8);\n if (bytes < 1024) return String(bytes).padStart(8);\n const units = [\"K\", \"M\", \"G\", \"T\"];\n let value = bytes;\n let unitIndex = -1;\n while (value >= 1024 && unitIndex < units.length - 1) {\n value /= 1024;\n unitIndex++;\n }\n const formatted = value < 10 ? value.toFixed(1) : String(Math.floor(value));\n return (formatted + units[unitIndex]!).padStart(8);\n}\n\nfunction colorize(name: string, isDirectory: boolean, isTTY: boolean): string {\n if (!isTTY || !isDirectory) return name;\n return `${BOLD_BLUE}${name}${RESET}`;\n}\n\nexport const ls: Command = async (ctx) => {\n const result = parser.parse(ctx.args);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n const { all: showAll, long: longFormat, onePerLine, recursive, humanReadable } = result.flags;\n const isTTY = ctx.stdout.isTTY;\n const paths = result.args.length === 0 ? [\".\"] : result.args;\n let needsBlankLine = false;\n\n const listDir = async (dirPath: string, displayPath: string, showHeader: boolean) => {\n if (needsBlankLine) await ctx.stdout.writeText(\"\\n\");\n needsBlankLine = true;\n\n if (showHeader) {\n await ctx.stdout.writeText(`${displayPath}:\\n`);\n }\n\n let entries = await ctx.fs.readdir(dirPath);\n\n if (!showAll) {\n entries = entries.filter((e) => !e.startsWith(\".\"));\n }\n\n entries.sort();\n\n if (longFormat) {\n for (const entry of entries) {\n const entryPath = ctx.fs.resolve(dirPath, entry);\n try {\n const entryStat = await ctx.fs.stat(entryPath);\n const isDir = entryStat.isDirectory();\n const type = isDir ? \"d\" : \"-\";\n const perms = \"rwxr-xr-x\";\n const size = formatSize(entryStat.size, humanReadable);\n const date = entryStat.mtime.toISOString().slice(0, 10);\n const name = colorize(entry, isDir, isTTY);\n await ctx.stdout.writeText(`${type}${perms} ${size} ${date} ${name}\\n`);\n } catch {\n await ctx.stdout.writeText(`?????????? ${entry}\\n`);\n }\n }\n } else if (onePerLine || !isTTY) {\n if (isTTY) {\n // -1 flag with TTY: still colorize directories\n const dirSet = new Set<string>();\n for (const entry of entries) {\n try {\n const entryStat = await ctx.fs.stat(ctx.fs.resolve(dirPath, entry));\n if (entryStat.isDirectory()) dirSet.add(entry);\n } catch {}\n }\n for (const entry of entries) {\n await ctx.stdout.writeText(colorize(entry, dirSet.has(entry), true) + \"\\n\");\n }\n } else {\n for (const entry of entries) {\n await ctx.stdout.writeText(entry + \"\\n\");\n }\n }\n } else {\n // TTY default: space-separated with colors\n if (entries.length > 0) {\n const dirSet = new Set<string>();\n for (const entry of entries) {\n try {\n const entryStat = await ctx.fs.stat(ctx.fs.resolve(dirPath, entry));\n if (entryStat.isDirectory()) dirSet.add(entry);\n } catch {}\n }\n const colored = entries.map((e) => colorize(e, dirSet.has(e), true));\n await ctx.stdout.writeText(colored.join(\" \") + \"\\n\");\n }\n }\n\n if (recursive) {\n for (const entry of entries) {\n const entryPath = ctx.fs.resolve(dirPath, entry);\n try {\n const entryStat = await ctx.fs.stat(entryPath);\n if (entryStat.isDirectory()) {\n const subDisplay = displayPath === \".\" ? entry : `${displayPath}/${entry}`;\n await listDir(entryPath, subDisplay, true);\n }\n } catch {\n // skip entries we can't stat\n }\n }\n }\n };\n\n for (let i = 0; i < paths.length; i++) {\n const pathArg = paths[i]!;\n const path = ctx.fs.resolve(ctx.cwd, pathArg);\n\n try {\n const stat = await ctx.fs.stat(path);\n\n if (stat.isFile()) {\n await ctx.stdout.writeText(ctx.fs.basename(path) + \"\\n\");\n continue;\n }\n\n const showHeader = recursive || paths.length > 1;\n await listDir(path, pathArg, showHeader);\n } catch (err) {\n await ctx.stderr.writeText(`ls: cannot access '${pathArg}': No such file or directory\\n`);\n return 1;\n }\n }\n\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACsD,IAAtD;AAUA,IAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,IACL,EAAE,OAAO,KAAK,MAAM,MAAM;AAAA,IAC1B,EAAE,OAAO,IAAI;AAAA,IACb,EAAE,OAAO,IAAI;AAAA,IACb,EAAE,OAAO,IAAI;AAAA,IACb,EAAE,OAAO,IAAI;AAAA,EACf;AAAA,EACA,OAAO;AACT;AAEA,IAAM,WAAoB,EAAE,KAAK,OAAO,MAAM,OAAO,YAAY,OAAO,WAAW,OAAO,eAAe,MAAM;AAE/G,IAAM,UAAU,CAAC,OAAgB,SAAyB;AAAA,EACxD,IAAI,KAAK,UAAU;AAAA,IAAK,MAAM,MAAM;AAAA,EACpC,IAAI,KAAK,UAAU;AAAA,IAAK,MAAM,OAAO;AAAA,EACrC,IAAI,KAAK,UAAU;AAAA,IAAK,MAAM,gBAAgB;AAAA,EAC9C,IAAI,KAAK,UAAU;AAAA,IAAK,MAAM,aAAa;AAAA,EAC3C,IAAI,KAAK,UAAU;AAAA,IAAK,MAAM,YAAY;AAAA;AAG5C,IAAM,SAAS,oCAAiB,MAAM,UAAU,OAAO;AAEvD,IAAM,YAAY;AAClB,IAAM,QAAQ;AAEd,SAAS,UAAU,CAAC,OAAe,eAAgC;AAAA,EACjE,IAAI,CAAC;AAAA,IAAe,OAAO,OAAO,KAAK,EAAE,SAAS,CAAC;AAAA,EACnD,IAAI,QAAQ;AAAA,IAAM,OAAO,OAAO,KAAK,EAAE,SAAS,CAAC;AAAA,EACjD,MAAM,QAAQ,CAAC,KAAK,KAAK,KAAK,GAAG;AAAA,EACjC,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A,MAAM,aAAa,aAAa,MAAM,SAAS;AAAA,MAC/C,MAAM,QAAQ,MAAM,SAAS,UAAU;AAAA,MACvC,OAAO,KAAK;AAAA,MACZ,MAAM,IAAI,OAAO,UAAU,sBAAsB;AAAA,CAAuC;AAAA,MACxF,OAAO;AAAA;AAAA,EAEX;AAAA,EAEA,OAAO;AAAA;",
|
|
8
|
+
"debugId": "A23859FA1A3F678664756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -72,4 +82,4 @@ var mkdir = async (ctx) => {
|
|
|
72
82
|
return 0;
|
|
73
83
|
};
|
|
74
84
|
|
|
75
|
-
//# debugId=
|
|
85
|
+
//# debugId=491624104B40A8E764756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\n\ninterface MkdirFlags {\n parents: boolean;\n}\n\nconst spec = {\n name: \"mkdir\",\n flags: [\n { short: \"p\", long: \"parents\" },\n ] as FlagDefinition[],\n usage: \"mkdir [-p] directory ...\",\n};\n\nconst defaults: MkdirFlags = { parents: false };\n\nconst handler = (flags: MkdirFlags, flag: FlagDefinition) => {\n if (flag.short === \"p\") flags.parents = true;\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\nexport const mkdir: Command = async (ctx) => {\n const result = parser.parse(ctx.args);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n const dirs = result.args;\n\n if (dirs.length === 0) {\n await ctx.stderr.writeText(\"mkdir: missing operand\\n\");\n return 1;\n }\n\n for (const dir of dirs) {\n const path = ctx.fs.resolve(ctx.cwd, dir);\n try {\n await ctx.fs.mkdir(path, { recursive: result.flags.parents });\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`mkdir: cannot create directory '${dir}': ${message}\\n`);\n return 1;\n }\n }\n\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
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|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -122,4 +132,4 @@ async function moveDirectory(ctx, src, dest, noClobber) {
|
|
|
122
132
|
await ctx.fs.rm(src, { recursive: true });
|
|
123
133
|
}
|
|
124
134
|
|
|
125
|
-
//# debugId=
|
|
135
|
+
//# debugId=54B51AB3A551E2C964756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\n\ninterface MvFlags {\n noClobber: boolean;\n}\n\nconst spec = {\n name: \"mv\",\n flags: [\n { short: \"n\", long: \"no-clobber\" },\n { short: \"f\", long: \"force\" },\n ] as FlagDefinition[],\n usage: \"mv [-nf] source ... dest\",\n};\n\nconst defaults: MvFlags = { noClobber: false };\n\nconst handler = (flags: MvFlags, flag: FlagDefinition) => {\n if (flag.short === \"n\") flags.noClobber = true;\n // -f is default behavior, so we don't need to do anything\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\nexport const mv: Command = async (ctx) => {\n const result = parser.parse(ctx.args);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n const { noClobber } = result.flags;\n const paths = result.args;\n\n if (paths.length < 2) {\n await ctx.stderr.writeText(\"mv: missing destination file operand\\n\");\n return 1;\n }\n\n const sources = paths.slice(0, -1);\n const dest = paths[paths.length - 1]!;\n const destPath = ctx.fs.resolve(ctx.cwd, dest);\n\n // Check if destination is a directory\n let destIsDir = false;\n try {\n const stat = await ctx.fs.stat(destPath);\n destIsDir = stat.isDirectory();\n } catch {\n // Destination doesn't exist\n }\n\n // If multiple sources, dest must be a directory\n if (sources.length > 1 && !destIsDir) {\n await ctx.stderr.writeText(`mv: target '${dest}' is not a directory\\n`);\n return 1;\n }\n\n for (const source of sources) {\n const srcPath = ctx.fs.resolve(ctx.cwd, source);\n\n try {\n // Check source exists\n await ctx.fs.stat(srcPath);\n\n // Determine final destination path\n const finalDest = destIsDir\n ? ctx.fs.resolve(destPath, ctx.fs.basename(srcPath))\n : destPath;\n\n // Check if dest exists and noClobber\n if (noClobber) {\n const exists = await ctx.fs.exists(finalDest);\n if (exists) continue; // Skip silently\n }\n\n // Move: copy then delete\n const srcStat = await ctx.fs.stat(srcPath);\n if (srcStat.isDirectory()) {\n await moveDirectory(ctx, srcPath, finalDest, noClobber);\n } else {\n const content = await ctx.fs.readFile(srcPath);\n await ctx.fs.writeFile(finalDest, content);\n await ctx.fs.rm(srcPath);\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`mv: cannot stat '${source}': ${message}\\n`);\n return 1;\n }\n }\n\n return 0;\n};\n\nasync function moveDirectory(\n ctx: Parameters<Command>[0],\n src: string,\n dest: string,\n noClobber: boolean\n): Promise<void> {\n // Create destination directory\n await ctx.fs.mkdir(dest, { recursive: true });\n\n // Read source directory contents\n const entries = await ctx.fs.readdir(src);\n\n for (const entry of entries) {\n const srcPath = ctx.fs.resolve(src, entry);\n const destPath = ctx.fs.resolve(dest, entry);\n\n const stat = await ctx.fs.stat(srcPath);\n\n if (stat.isDirectory()) {\n await moveDirectory(ctx, srcPath, destPath, noClobber);\n } else {\n if (noClobber) {\n const exists = await ctx.fs.exists(destPath);\n if (exists) continue;\n }\n const content = await ctx.fs.readFile(srcPath);\n await ctx.fs.writeFile(destPath, content);\n }\n }\n\n // Remove source directory after copying\n await ctx.fs.rm(src, { recursive: true });\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACsD,IAAtD;AAMA,IAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,IACL,EAAE,OAAO,KAAK,MAAM,aAAa;AAAA,IACjC,EAAE,OAAO,KAAK,MAAM,QAAQ;AAAA,EAC9B;AAAA,EACA,OAAO;AACT;AAEA,IAAM,WAAoB,EAAE,WA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AAI,GAAG,SAAS,OAAO;AAAA,MAC7C,MAAM,IAAI,GAAG,UAAU,UAAU,OAAO;AAAA;AAAA,EAE5C;AAAA,EAGA,MAAM,IAAI,GAAG,GAAG,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA;",
|
|
8
|
+
"debugId": "54B51AB3A551E2C964756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -50,4 +60,4 @@ var pwd = async (ctx) => {
|
|
|
50
60
|
return 0;
|
|
51
61
|
};
|
|
52
62
|
|
|
53
|
-
//# debugId=
|
|
63
|
+
//# debugId=C3B66191A4A32E4464756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\n\nconst spec = {\n name: \"pwd\",\n flags: [] as FlagDefinition[],\n usage: \"pwd\",\n};\n\nconst parser = createFlagParser(spec, {}, () => {});\n\nexport const pwd: Command = async (ctx) => {\n const result = parser.parse(ctx.args);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n await ctx.stdout.writeText(ctx.cwd + \"\\n\");\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACsD,IAAtD;AAEA,IAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,OAAO,CAAC;AAAA,EACR,OAAO;AACT;AAEA,IAAM,SAAS,oCAAiB,MAAM,CAAC,GAAG,MAAM,EAAE;AAE3C,IAAM,MAAe,OAAO,QAAQ;AAAA,EACzC,MAAM,SAAS,OAAO,MAAM,IAAI,IAAI;AAAA,EAEpC,IAAI,OAAO,OAAO;AAAA,IAChB,MAAM,OAAO,WAAW,OAAO,OAAO,IAAI,MAAM;AAAA,IAChD,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,IAAI,OAAO,UAAU,IAAI,MAAM;AAAA,CAAI;AAAA,EACzC,OAAO;AAAA;",
|
|
8
|
+
"debugId": "C3B66191A4A32E4464756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -82,4 +92,4 @@ var rm = async (ctx) => {
|
|
|
82
92
|
return 0;
|
|
83
93
|
};
|
|
84
94
|
|
|
85
|
-
//# debugId=
|
|
95
|
+
//# debugId=8C85CFAD6AB20CF464756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Command } from \"../../types.cjs\";\nimport { createFlagParser, type FlagDefinition } from \"../../utils/flag-parser.cjs\";\n\ninterface RmFlags {\n recursive: boolean;\n force: boolean;\n}\n\nconst spec = {\n name: \"rm\",\n flags: [\n { short: \"r\", long: \"recursive\" },\n { short: \"R\" },\n { short: \"f\", long: \"force\" },\n ] as FlagDefinition[],\n usage: \"rm [-rf] file ...\",\n};\n\nconst defaults: RmFlags = { recursive: false, force: false };\n\nconst handler = (flags: RmFlags, flag: FlagDefinition) => {\n if (flag.short === \"r\" || flag.short === \"R\") flags.recursive = true;\n if (flag.short === \"f\") flags.force = true;\n};\n\nconst parser = createFlagParser(spec, defaults, handler);\n\nexport const rm: Command = async (ctx) => {\n const result = parser.parse(ctx.args);\n\n if (result.error) {\n await parser.writeError(result.error, ctx.stderr);\n return 1;\n }\n\n const { recursive, force } = result.flags;\n const targets = result.args;\n\n if (targets.length === 0) {\n if (!force) {\n await ctx.stderr.writeText(\"rm: missing operand\\n\");\n return 1;\n }\n return 0;\n }\n\n for (const target of targets) {\n const path = ctx.fs.resolve(ctx.cwd, target);\n try {\n await ctx.fs.rm(path, { recursive, force });\n } catch (err) {\n if (!force) {\n const message = err instanceof Error ? err.message : String(err);\n await ctx.stderr.writeText(`rm: cannot remove '${target}': ${message}\\n`);\n return 1;\n }\n }\n }\n\n return 0;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
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AAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,QAC/D,MAAM,IAAI,OAAO,UAAU,sBAAsB,YAAY;AAAA,CAAW;AAAA,QACxE,OAAO;AAAA,MACT;AAAA;AAAA,EAEJ;AAAA,EAEA,OAAO;AAAA;",
|
|
8
|
+
"debugId": "8C85CFAD6AB20CF464756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -660,4 +670,4 @@ var sed = async (ctx) => {
|
|
|
660
670
|
return 0;
|
|
661
671
|
};
|
|
662
672
|
|
|
663
|
-
//# debugId=
|
|
673
|
+
//# debugId=310CF798610B6B7364756E2164756E21
|