track-cli 3.0.0-rc
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/LICENSE +7 -0
- package/README.md +3 -0
- package/esm/_dnt.polyfills.d.ts +6 -0
- package/esm/_dnt.polyfills.js +1 -0
- package/esm/_dnt.shims.d.ts +19 -0
- package/esm/_dnt.shims.js +78 -0
- package/esm/deps/deno.land/std@0.170.0/fmt/colors.d.ts +270 -0
- package/esm/deps/deno.land/std@0.170.0/fmt/colors.js +473 -0
- package/esm/deps/deno.land/std@0.195.0/_util/os.d.ts +4 -0
- package/esm/deps/deno.land/std@0.195.0/_util/os.js +18 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assert.d.ts +2 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assert.js +8 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assertion_error.d.ts +4 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assertion_error.js +12 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/_common.d.ts +50 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/_common.js +545 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/constants.d.ts +55 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/constants.js +57 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/day_of_year.d.ts +26 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/day_of_year.js +45 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/difference.d.ts +38 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/difference.js +93 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/format.d.ts +22 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/format.js +28 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/is_leap.d.ts +49 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/is_leap.js +60 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/mod.d.ts +43 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/mod.js +45 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/parse.d.ts +21 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/parse.js +29 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/to_imf.d.ts +17 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/to_imf.js +44 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/week_of_year.d.ts +13 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/week_of_year.js +38 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/colors.d.ts +270 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/colors.js +474 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/duration.d.ts +15 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/duration.js +96 -0
- package/esm/deps/deno.land/std@0.195.0/fs/_util.d.ts +35 -0
- package/esm/deps/deno.land/std@0.195.0/fs/_util.js +80 -0
- package/esm/deps/deno.land/std@0.195.0/fs/copy.d.ts +51 -0
- package/esm/deps/deno.land/std@0.195.0/fs/copy.js +244 -0
- package/esm/deps/deno.land/std@0.195.0/fs/empty_dir.d.ts +31 -0
- package/esm/deps/deno.land/std@0.195.0/fs/empty_dir.js +74 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_dir.d.ts +27 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_dir.js +55 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_file.d.ts +33 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_file.js +75 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_link.d.ts +31 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_link.js +43 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_symlink.d.ts +17 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_symlink.js +68 -0
- package/esm/deps/deno.land/std@0.195.0/fs/eol.d.ts +40 -0
- package/esm/deps/deno.land/std@0.195.0/fs/eol.js +53 -0
- package/esm/deps/deno.land/std@0.195.0/fs/exists.d.ts +102 -0
- package/esm/deps/deno.land/std@0.195.0/fs/exists.js +163 -0
- package/esm/deps/deno.land/std@0.195.0/fs/expand_glob.d.ts +37 -0
- package/esm/deps/deno.land/std@0.195.0/fs/expand_glob.js +216 -0
- package/esm/deps/deno.land/std@0.195.0/fs/mod.d.ts +16 -0
- package/esm/deps/deno.land/std@0.195.0/fs/mod.js +17 -0
- package/esm/deps/deno.land/std@0.195.0/fs/move.d.ts +29 -0
- package/esm/deps/deno.land/std@0.195.0/fs/move.js +88 -0
- package/esm/deps/deno.land/std@0.195.0/fs/walk.d.ts +40 -0
- package/esm/deps/deno.land/std@0.195.0/fs/walk.js +158 -0
- package/esm/deps/deno.land/std@0.195.0/path/_constants.d.ts +39 -0
- package/esm/deps/deno.land/std@0.195.0/path/_constants.js +46 -0
- package/esm/deps/deno.land/std@0.195.0/path/_interface.d.ts +26 -0
- package/esm/deps/deno.land/std@0.195.0/path/_interface.js +3 -0
- package/esm/deps/deno.land/std@0.195.0/path/_util.d.ts +11 -0
- package/esm/deps/deno.land/std@0.195.0/path/_util.js +161 -0
- package/esm/deps/deno.land/std@0.195.0/path/common.d.ts +13 -0
- package/esm/deps/deno.land/std@0.195.0/path/common.js +36 -0
- package/esm/deps/deno.land/std@0.195.0/path/glob.d.ts +83 -0
- package/esm/deps/deno.land/std@0.195.0/path/glob.js +361 -0
- package/esm/deps/deno.land/std@0.195.0/path/mod.d.ts +9 -0
- package/esm/deps/deno.land/std@0.195.0/path/mod.js +33 -0
- package/esm/deps/deno.land/std@0.195.0/path/posix.d.ts +86 -0
- package/esm/deps/deno.land/std@0.195.0/path/posix.js +442 -0
- package/esm/deps/deno.land/std@0.195.0/path/separator.d.ts +2 -0
- package/esm/deps/deno.land/std@0.195.0/path/separator.js +5 -0
- package/esm/deps/deno.land/std@0.195.0/path/win32.d.ts +91 -0
- package/esm/deps/deno.land/std@0.195.0/path/win32.js +909 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/_utils/distance.d.ts +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/_utils/distance.js +26 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_errors.d.ts +76 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_errors.js +154 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_utils.d.ts +32 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_utils.js +105 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/command.d.ts +831 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/command.js +1701 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_bash_completions_generator.d.ts +17 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_bash_completions_generator.js +201 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_fish_completions_generator.d.ts +14 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_fish_completions_generator.js +141 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_zsh_completions_generator.d.ts +21 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_zsh_completions_generator.js +285 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/bash.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/bash.js +38 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/complete.d.ts +8 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/complete.js +32 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/fish.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/fish.js +38 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/mod.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/mod.js +46 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/zsh.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/zsh.js +38 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deprecated.d.ts +45 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deprecated.js +2 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deps.d.ts +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deps.js +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/_help_generator.d.ts +27 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/_help_generator.js +323 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/mod.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/mod.js +34 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/mod.d.ts +18 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/mod.js +17 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/type.d.ts +41 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/type.js +24 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/action_list.d.ts +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/action_list.js +20 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/boolean.d.ts +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/boolean.js +13 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/child_command.d.ts +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/child_command.js +27 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/command.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/command.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/enum.d.ts +10 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/enum.js +29 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/file.d.ts +5 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/file.js +12 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/integer.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/integer.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/number.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/number.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/string.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/string.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types.d.ts +118 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types.js +2 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/mod.d.ts +5 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/mod.js +5 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/deno_land.d.ts +14 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/deno_land.js +46 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/github.d.ts +26 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/github.js +118 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/nest_land.d.ts +14 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/nest_land.js +55 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider.d.ts +27 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider.js +102 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/upgrade_command.d.ts +17 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/upgrade_command.js +75 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_errors.d.ts +60 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_errors.js +117 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_utils.d.ts +18 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_utils.js +106 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_validate_flags.d.ts +10 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_validate_flags.js +157 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/deprecated.d.ts +24 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/deprecated.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/flags.d.ts +33 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/flags.js +402 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/boolean.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/boolean.js +11 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/integer.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/integer.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/number.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/number.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/string.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/string.js +4 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types.d.ts +59 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types.js +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/border.d.ts +20 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/border.js +18 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/cell.d.ts +78 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/cell.js +128 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/deps.d.ts +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/deps.js +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.d.ts +99 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.js +529 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/row.d.ts +49 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/row.js +74 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/table.d.ts +135 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/table.js +237 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/utils.d.ts +13 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/utils.js +60 -0
- package/esm/package.json +3 -0
- package/esm/src/action/add.d.ts +1 -0
- package/esm/src/action/add.js +57 -0
- package/esm/src/action/clone.d.ts +6 -0
- package/esm/src/action/clone.js +108 -0
- package/esm/src/action/lang.d.ts +1 -0
- package/esm/src/action/lang.js +40 -0
- package/esm/src/action/pull.d.ts +1 -0
- package/esm/src/action/pull.js +22 -0
- package/esm/src/action/remove.d.ts +4 -0
- package/esm/src/action/remove.js +67 -0
- package/esm/src/action/reset.d.ts +1 -0
- package/esm/src/action/reset.js +21 -0
- package/esm/src/action/run.d.ts +4 -0
- package/esm/src/action/run.js +163 -0
- package/esm/src/action/status.d.ts +1 -0
- package/esm/src/action/status.js +5 -0
- package/esm/src/main.d.ts +2 -0
- package/esm/src/main.js +96 -0
- package/esm/src/meta.d.ts +3 -0
- package/esm/src/meta.js +51 -0
- package/esm/src/orca/client.d.ts +20 -0
- package/esm/src/orca/client.js +152 -0
- package/esm/src/orca/types.d.ts +54 -0
- package/esm/src/orca/types.js +12 -0
- package/esm/src/shared/config.d.ts +24 -0
- package/esm/src/shared/config.js +24 -0
- package/esm/src/shared/errors.d.ts +82 -0
- package/esm/src/shared/errors.js +228 -0
- package/esm/src/shared/file.d.ts +30 -0
- package/esm/src/shared/file.js +110 -0
- package/esm/src/shared/mod.d.ts +40 -0
- package/esm/src/shared/mod.js +383 -0
- package/esm/src/shared/types.d.ts +12 -0
- package/esm/src/shared/types.js +1 -0
- package/esm/src/track/client.d.ts +60 -0
- package/esm/src/track/client.js +268 -0
- package/esm/src/track/types.d.ts +210 -0
- package/esm/src/track/types.js +40 -0
- package/package.json +35 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for working with the filesystem.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
export * from "./empty_dir.js";
|
|
7
|
+
export * from "./ensure_dir.js";
|
|
8
|
+
export * from "./ensure_file.js";
|
|
9
|
+
export * from "./ensure_link.js";
|
|
10
|
+
export * from "./ensure_symlink.js";
|
|
11
|
+
export * from "./exists.js";
|
|
12
|
+
export * from "./expand_glob.js";
|
|
13
|
+
export * from "./move.js";
|
|
14
|
+
export * from "./copy.js";
|
|
15
|
+
export * from "./walk.js";
|
|
16
|
+
export * from "./eol.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
/**
|
|
3
|
+
* Helpers for working with the filesystem.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export * from "./empty_dir.js";
|
|
8
|
+
export * from "./ensure_dir.js";
|
|
9
|
+
export * from "./ensure_file.js";
|
|
10
|
+
export * from "./ensure_link.js";
|
|
11
|
+
export * from "./ensure_symlink.js";
|
|
12
|
+
export * from "./exists.js";
|
|
13
|
+
export * from "./expand_glob.js";
|
|
14
|
+
export * from "./move.js";
|
|
15
|
+
export * from "./copy.js";
|
|
16
|
+
export * from "./walk.js";
|
|
17
|
+
export * from "./eol.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare class SubdirectoryMoveError extends Error {
|
|
3
|
+
constructor(src: string | URL, dest: string | URL);
|
|
4
|
+
}
|
|
5
|
+
interface MoveOptions {
|
|
6
|
+
overwrite?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Moves a file or directory.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { move } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
|
14
|
+
*
|
|
15
|
+
* move("./foo", "./bar"); // returns a promise
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function move(src: string | URL, dest: string | URL, { overwrite }?: MoveOptions): Promise<undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Moves a file or directory synchronously.
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { moveSync } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
|
24
|
+
*
|
|
25
|
+
* moveSync("./foo", "./bar"); // void
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function moveSync(src: string | URL, dest: string | URL, { overwrite }?: MoveOptions): void;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
import * as dntShim from "../../../../_dnt.shims.js";
|
|
3
|
+
import { isSamePath, isSubdir } from "./_util.js";
|
|
4
|
+
const EXISTS_ERROR = new dntShim.Deno.errors.AlreadyExists("dest already exists.");
|
|
5
|
+
export class SubdirectoryMoveError extends Error {
|
|
6
|
+
constructor(src, dest) {
|
|
7
|
+
super(`Cannot move '${src}' to a subdirectory of itself, '${dest}'.`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Moves a file or directory.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { move } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
|
16
|
+
*
|
|
17
|
+
* move("./foo", "./bar"); // returns a promise
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export async function move(src, dest, { overwrite = false } = {}) {
|
|
21
|
+
const srcStat = await dntShim.Deno.stat(src);
|
|
22
|
+
if (srcStat.isDirectory &&
|
|
23
|
+
(isSubdir(src, dest) || isSamePath(src, dest))) {
|
|
24
|
+
throw new SubdirectoryMoveError(src, dest);
|
|
25
|
+
}
|
|
26
|
+
if (overwrite) {
|
|
27
|
+
if (isSamePath(src, dest))
|
|
28
|
+
return;
|
|
29
|
+
try {
|
|
30
|
+
await dntShim.Deno.remove(dest, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (!(error instanceof dntShim.Deno.errors.NotFound)) {
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
try {
|
|
40
|
+
await dntShim.Deno.lstat(dest);
|
|
41
|
+
return Promise.reject(EXISTS_ERROR);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Do nothing...
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
await dntShim.Deno.rename(src, dest);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Moves a file or directory synchronously.
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { moveSync } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
|
54
|
+
*
|
|
55
|
+
* moveSync("./foo", "./bar"); // void
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function moveSync(src, dest, { overwrite = false } = {}) {
|
|
59
|
+
const srcStat = dntShim.Deno.statSync(src);
|
|
60
|
+
if (srcStat.isDirectory &&
|
|
61
|
+
(isSubdir(src, dest) || isSamePath(src, dest))) {
|
|
62
|
+
throw new SubdirectoryMoveError(src, dest);
|
|
63
|
+
}
|
|
64
|
+
if (overwrite) {
|
|
65
|
+
if (isSamePath(src, dest))
|
|
66
|
+
return;
|
|
67
|
+
try {
|
|
68
|
+
dntShim.Deno.removeSync(dest, { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (!(error instanceof dntShim.Deno.errors.NotFound)) {
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
try {
|
|
78
|
+
dntShim.Deno.lstatSync(dest);
|
|
79
|
+
throw EXISTS_ERROR;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (error === EXISTS_ERROR) {
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
dntShim.Deno.renameSync(src, dest);
|
|
88
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { WalkEntry } from "./_util.js";
|
|
3
|
+
export declare class WalkError extends Error {
|
|
4
|
+
cause: unknown;
|
|
5
|
+
name: string;
|
|
6
|
+
path: string;
|
|
7
|
+
constructor(cause: unknown, path: string);
|
|
8
|
+
}
|
|
9
|
+
export interface WalkOptions {
|
|
10
|
+
/** @default {Infinity} */
|
|
11
|
+
maxDepth?: number;
|
|
12
|
+
/** @default {true} */
|
|
13
|
+
includeFiles?: boolean;
|
|
14
|
+
/** @default {true} */
|
|
15
|
+
includeDirs?: boolean;
|
|
16
|
+
/** @default {false} */
|
|
17
|
+
followSymlinks?: boolean;
|
|
18
|
+
exts?: string[];
|
|
19
|
+
match?: RegExp[];
|
|
20
|
+
skip?: RegExp[];
|
|
21
|
+
}
|
|
22
|
+
export type { WalkEntry };
|
|
23
|
+
/**
|
|
24
|
+
* Walks the file tree rooted at root, yielding each file or directory in the
|
|
25
|
+
* tree filtered according to the given options.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { walk } from "https://deno.land/std@$STD_VERSION/fs/walk.ts";
|
|
30
|
+
* import { assert } from "https://deno.land/std@$STD_VERSION/assert/assert.ts";
|
|
31
|
+
*
|
|
32
|
+
* for await (const entry of walk(".")) {
|
|
33
|
+
* console.log(entry.path);
|
|
34
|
+
* assert(entry.isFile);
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function walk(root: string | URL, { maxDepth, includeFiles, includeDirs, followSymlinks, exts, match, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
|
|
39
|
+
/** Same as walk() but uses synchronous ops */
|
|
40
|
+
export declare function walkSync(root: string | URL, { maxDepth, includeFiles, includeDirs, followSymlinks, exts, match, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
// Documentation and interface for walk were adapted from Go
|
|
3
|
+
// https://golang.org/pkg/path/filepath/#Walk
|
|
4
|
+
// Copyright 2009 The Go Authors. All rights reserved. BSD license.
|
|
5
|
+
import * as dntShim from "../../../../_dnt.shims.js";
|
|
6
|
+
import { assert } from "../assert/assert.js";
|
|
7
|
+
import { join, normalize } from "../path/mod.js";
|
|
8
|
+
import { createWalkEntry, createWalkEntrySync, toPathString, } from "./_util.js";
|
|
9
|
+
export class WalkError extends Error {
|
|
10
|
+
constructor(cause, path) {
|
|
11
|
+
super(`${cause instanceof Error ? cause.message : cause} for path "${path}"`);
|
|
12
|
+
Object.defineProperty(this, "cause", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "name", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: "WalkError"
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "path", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
this.path = path;
|
|
31
|
+
this.cause = cause;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function include(path, exts, match, skip) {
|
|
35
|
+
if (exts && !exts.some((ext) => path.endsWith(ext))) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (match && !match.some((pattern) => !!path.match(pattern))) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (skip && skip.some((pattern) => !!path.match(pattern))) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
function wrapErrorWithPath(err, root) {
|
|
47
|
+
if (err instanceof WalkError)
|
|
48
|
+
return err;
|
|
49
|
+
return new WalkError(err, root);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Walks the file tree rooted at root, yielding each file or directory in the
|
|
53
|
+
* tree filtered according to the given options.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { walk } from "https://deno.land/std@$STD_VERSION/fs/walk.ts";
|
|
58
|
+
* import { assert } from "https://deno.land/std@$STD_VERSION/assert/assert.ts";
|
|
59
|
+
*
|
|
60
|
+
* for await (const entry of walk(".")) {
|
|
61
|
+
* console.log(entry.path);
|
|
62
|
+
* assert(entry.isFile);
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export async function* walk(root, { maxDepth = Infinity, includeFiles = true, includeDirs = true, followSymlinks = false, exts = undefined, match = undefined, skip = undefined, } = {}) {
|
|
67
|
+
if (maxDepth < 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
root = toPathString(root);
|
|
71
|
+
if (includeDirs && include(root, exts, match, skip)) {
|
|
72
|
+
yield await createWalkEntry(root);
|
|
73
|
+
}
|
|
74
|
+
if (maxDepth < 1 || !include(root, undefined, undefined, skip)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
for await (const entry of dntShim.Deno.readDir(root)) {
|
|
79
|
+
assert(entry.name != null);
|
|
80
|
+
let path = join(root, entry.name);
|
|
81
|
+
let { isSymlink, isDirectory } = entry;
|
|
82
|
+
if (isSymlink) {
|
|
83
|
+
if (!followSymlinks)
|
|
84
|
+
continue;
|
|
85
|
+
path = await dntShim.Deno.realPath(path);
|
|
86
|
+
// Caveat emptor: don't assume |path| is not a symlink. realpath()
|
|
87
|
+
// resolves symlinks but another process can replace the file system
|
|
88
|
+
// entity with a different type of entity before we call lstat().
|
|
89
|
+
({ isSymlink, isDirectory } = await dntShim.Deno.lstat(path));
|
|
90
|
+
}
|
|
91
|
+
if (isSymlink || isDirectory) {
|
|
92
|
+
yield* walk(path, {
|
|
93
|
+
maxDepth: maxDepth - 1,
|
|
94
|
+
includeFiles,
|
|
95
|
+
includeDirs,
|
|
96
|
+
followSymlinks,
|
|
97
|
+
exts,
|
|
98
|
+
match,
|
|
99
|
+
skip,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else if (includeFiles && include(path, exts, match, skip)) {
|
|
103
|
+
yield { path, ...entry };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
throw wrapErrorWithPath(err, normalize(root));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Same as walk() but uses synchronous ops */
|
|
112
|
+
export function* walkSync(root, { maxDepth = Infinity, includeFiles = true, includeDirs = true, followSymlinks = false, exts = undefined, match = undefined, skip = undefined, } = {}) {
|
|
113
|
+
root = toPathString(root);
|
|
114
|
+
if (maxDepth < 0) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (includeDirs && include(root, exts, match, skip)) {
|
|
118
|
+
yield createWalkEntrySync(root);
|
|
119
|
+
}
|
|
120
|
+
if (maxDepth < 1 || !include(root, undefined, undefined, skip)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
let entries;
|
|
124
|
+
try {
|
|
125
|
+
entries = dntShim.Deno.readDirSync(root);
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
throw wrapErrorWithPath(err, normalize(root));
|
|
129
|
+
}
|
|
130
|
+
for (const entry of entries) {
|
|
131
|
+
assert(entry.name != null);
|
|
132
|
+
let path = join(root, entry.name);
|
|
133
|
+
let { isSymlink, isDirectory } = entry;
|
|
134
|
+
if (isSymlink) {
|
|
135
|
+
if (!followSymlinks)
|
|
136
|
+
continue;
|
|
137
|
+
path = dntShim.Deno.realPathSync(path);
|
|
138
|
+
// Caveat emptor: don't assume |path| is not a symlink. realpath()
|
|
139
|
+
// resolves symlinks but another process can replace the file system
|
|
140
|
+
// entity with a different type of entity before we call lstat().
|
|
141
|
+
({ isSymlink, isDirectory } = dntShim.Deno.lstatSync(path));
|
|
142
|
+
}
|
|
143
|
+
if (isSymlink || isDirectory) {
|
|
144
|
+
yield* walkSync(path, {
|
|
145
|
+
maxDepth: maxDepth - 1,
|
|
146
|
+
includeFiles,
|
|
147
|
+
includeDirs,
|
|
148
|
+
followSymlinks,
|
|
149
|
+
exts,
|
|
150
|
+
match,
|
|
151
|
+
skip,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else if (includeFiles && include(path, exts, match, skip)) {
|
|
155
|
+
yield { path, ...entry };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const CHAR_UPPERCASE_A = 65;
|
|
2
|
+
export declare const CHAR_LOWERCASE_A = 97;
|
|
3
|
+
export declare const CHAR_UPPERCASE_Z = 90;
|
|
4
|
+
export declare const CHAR_LOWERCASE_Z = 122;
|
|
5
|
+
export declare const CHAR_DOT = 46;
|
|
6
|
+
export declare const CHAR_FORWARD_SLASH = 47;
|
|
7
|
+
export declare const CHAR_BACKWARD_SLASH = 92;
|
|
8
|
+
export declare const CHAR_VERTICAL_LINE = 124;
|
|
9
|
+
export declare const CHAR_COLON = 58;
|
|
10
|
+
export declare const CHAR_QUESTION_MARK = 63;
|
|
11
|
+
export declare const CHAR_UNDERSCORE = 95;
|
|
12
|
+
export declare const CHAR_LINE_FEED = 10;
|
|
13
|
+
export declare const CHAR_CARRIAGE_RETURN = 13;
|
|
14
|
+
export declare const CHAR_TAB = 9;
|
|
15
|
+
export declare const CHAR_FORM_FEED = 12;
|
|
16
|
+
export declare const CHAR_EXCLAMATION_MARK = 33;
|
|
17
|
+
export declare const CHAR_HASH = 35;
|
|
18
|
+
export declare const CHAR_SPACE = 32;
|
|
19
|
+
export declare const CHAR_NO_BREAK_SPACE = 160;
|
|
20
|
+
export declare const CHAR_ZERO_WIDTH_NOBREAK_SPACE = 65279;
|
|
21
|
+
export declare const CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
22
|
+
export declare const CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
23
|
+
export declare const CHAR_LEFT_ANGLE_BRACKET = 60;
|
|
24
|
+
export declare const CHAR_RIGHT_ANGLE_BRACKET = 62;
|
|
25
|
+
export declare const CHAR_LEFT_CURLY_BRACKET = 123;
|
|
26
|
+
export declare const CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
27
|
+
export declare const CHAR_HYPHEN_MINUS = 45;
|
|
28
|
+
export declare const CHAR_PLUS = 43;
|
|
29
|
+
export declare const CHAR_DOUBLE_QUOTE = 34;
|
|
30
|
+
export declare const CHAR_SINGLE_QUOTE = 39;
|
|
31
|
+
export declare const CHAR_PERCENT = 37;
|
|
32
|
+
export declare const CHAR_SEMICOLON = 59;
|
|
33
|
+
export declare const CHAR_CIRCUMFLEX_ACCENT = 94;
|
|
34
|
+
export declare const CHAR_GRAVE_ACCENT = 96;
|
|
35
|
+
export declare const CHAR_AT = 64;
|
|
36
|
+
export declare const CHAR_AMPERSAND = 38;
|
|
37
|
+
export declare const CHAR_EQUAL = 61;
|
|
38
|
+
export declare const CHAR_0 = 48;
|
|
39
|
+
export declare const CHAR_9 = 57;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
// Copyright the Browserify authors. MIT License.
|
|
3
|
+
// Ported from https://github.com/browserify/path-browserify/
|
|
4
|
+
// This module is browser compatible.
|
|
5
|
+
// Alphabet chars.
|
|
6
|
+
export const CHAR_UPPERCASE_A = 65; /* A */
|
|
7
|
+
export const CHAR_LOWERCASE_A = 97; /* a */
|
|
8
|
+
export const CHAR_UPPERCASE_Z = 90; /* Z */
|
|
9
|
+
export const CHAR_LOWERCASE_Z = 122; /* z */
|
|
10
|
+
// Non-alphabetic chars.
|
|
11
|
+
export const CHAR_DOT = 46; /* . */
|
|
12
|
+
export const CHAR_FORWARD_SLASH = 47; /* / */
|
|
13
|
+
export const CHAR_BACKWARD_SLASH = 92; /* \ */
|
|
14
|
+
export const CHAR_VERTICAL_LINE = 124; /* | */
|
|
15
|
+
export const CHAR_COLON = 58; /* : */
|
|
16
|
+
export const CHAR_QUESTION_MARK = 63; /* ? */
|
|
17
|
+
export const CHAR_UNDERSCORE = 95; /* _ */
|
|
18
|
+
export const CHAR_LINE_FEED = 10; /* \n */
|
|
19
|
+
export const CHAR_CARRIAGE_RETURN = 13; /* \r */
|
|
20
|
+
export const CHAR_TAB = 9; /* \t */
|
|
21
|
+
export const CHAR_FORM_FEED = 12; /* \f */
|
|
22
|
+
export const CHAR_EXCLAMATION_MARK = 33; /* ! */
|
|
23
|
+
export const CHAR_HASH = 35; /* # */
|
|
24
|
+
export const CHAR_SPACE = 32; /* */
|
|
25
|
+
export const CHAR_NO_BREAK_SPACE = 160; /* \u00A0 */
|
|
26
|
+
export const CHAR_ZERO_WIDTH_NOBREAK_SPACE = 65279; /* \uFEFF */
|
|
27
|
+
export const CHAR_LEFT_SQUARE_BRACKET = 91; /* [ */
|
|
28
|
+
export const CHAR_RIGHT_SQUARE_BRACKET = 93; /* ] */
|
|
29
|
+
export const CHAR_LEFT_ANGLE_BRACKET = 60; /* < */
|
|
30
|
+
export const CHAR_RIGHT_ANGLE_BRACKET = 62; /* > */
|
|
31
|
+
export const CHAR_LEFT_CURLY_BRACKET = 123; /* { */
|
|
32
|
+
export const CHAR_RIGHT_CURLY_BRACKET = 125; /* } */
|
|
33
|
+
export const CHAR_HYPHEN_MINUS = 45; /* - */
|
|
34
|
+
export const CHAR_PLUS = 43; /* + */
|
|
35
|
+
export const CHAR_DOUBLE_QUOTE = 34; /* " */
|
|
36
|
+
export const CHAR_SINGLE_QUOTE = 39; /* ' */
|
|
37
|
+
export const CHAR_PERCENT = 37; /* % */
|
|
38
|
+
export const CHAR_SEMICOLON = 59; /* ; */
|
|
39
|
+
export const CHAR_CIRCUMFLEX_ACCENT = 94; /* ^ */
|
|
40
|
+
export const CHAR_GRAVE_ACCENT = 96; /* ` */
|
|
41
|
+
export const CHAR_AT = 64; /* @ */
|
|
42
|
+
export const CHAR_AMPERSAND = 38; /* & */
|
|
43
|
+
export const CHAR_EQUAL = 61; /* = */
|
|
44
|
+
// Digits
|
|
45
|
+
export const CHAR_0 = 48; /* 0 */
|
|
46
|
+
export const CHAR_9 = 57; /* 9 */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A parsed path object generated by path.parse() or consumed by path.format().
|
|
3
|
+
*/
|
|
4
|
+
export interface ParsedPath {
|
|
5
|
+
/**
|
|
6
|
+
* The root of the path such as '/' or 'c:\'
|
|
7
|
+
*/
|
|
8
|
+
root: string;
|
|
9
|
+
/**
|
|
10
|
+
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
|
11
|
+
*/
|
|
12
|
+
dir: string;
|
|
13
|
+
/**
|
|
14
|
+
* The file name including extension (if any) such as 'index.html'
|
|
15
|
+
*/
|
|
16
|
+
base: string;
|
|
17
|
+
/**
|
|
18
|
+
* The file extension (if any) such as '.html'
|
|
19
|
+
*/
|
|
20
|
+
ext: string;
|
|
21
|
+
/**
|
|
22
|
+
* The file name without extension (if any) such as 'index'
|
|
23
|
+
*/
|
|
24
|
+
name: string;
|
|
25
|
+
}
|
|
26
|
+
export type FormatInputPathObject = Partial<ParsedPath>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FormatInputPathObject } from "./_interface.js";
|
|
2
|
+
export declare function assertPath(path: string): void;
|
|
3
|
+
export declare function isPosixPathSeparator(code: number): boolean;
|
|
4
|
+
export declare function isPathSeparator(code: number): boolean;
|
|
5
|
+
export declare function isWindowsDeviceRoot(code: number): boolean;
|
|
6
|
+
export declare function normalizeString(path: string, allowAboveRoot: boolean, separator: string, isPathSeparator: (code: number) => boolean): string;
|
|
7
|
+
export declare function _format(sep: string, pathObject: FormatInputPathObject): string;
|
|
8
|
+
export declare function encodeWhitespace(string: string): string;
|
|
9
|
+
export declare function lastPathSegment(path: string, isSep: (char: number) => boolean, start?: number): string;
|
|
10
|
+
export declare function stripTrailingSeparators(segment: string, isSep: (char: number) => boolean): string;
|
|
11
|
+
export declare function stripSuffix(name: string, suffix: string): string;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
// Copyright the Browserify authors. MIT License.
|
|
3
|
+
// Ported from https://github.com/browserify/path-browserify/
|
|
4
|
+
// This module is browser compatible.
|
|
5
|
+
import { CHAR_BACKWARD_SLASH, CHAR_DOT, CHAR_FORWARD_SLASH, CHAR_LOWERCASE_A, CHAR_LOWERCASE_Z, CHAR_UPPERCASE_A, CHAR_UPPERCASE_Z, } from "./_constants.js";
|
|
6
|
+
export function assertPath(path) {
|
|
7
|
+
if (typeof path !== "string") {
|
|
8
|
+
throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function isPosixPathSeparator(code) {
|
|
12
|
+
return code === CHAR_FORWARD_SLASH;
|
|
13
|
+
}
|
|
14
|
+
export function isPathSeparator(code) {
|
|
15
|
+
return isPosixPathSeparator(code) || code === CHAR_BACKWARD_SLASH;
|
|
16
|
+
}
|
|
17
|
+
export function isWindowsDeviceRoot(code) {
|
|
18
|
+
return ((code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z) ||
|
|
19
|
+
(code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z));
|
|
20
|
+
}
|
|
21
|
+
// Resolves . and .. elements in a path with directory names
|
|
22
|
+
export function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
|
|
23
|
+
let res = "";
|
|
24
|
+
let lastSegmentLength = 0;
|
|
25
|
+
let lastSlash = -1;
|
|
26
|
+
let dots = 0;
|
|
27
|
+
let code;
|
|
28
|
+
for (let i = 0, len = path.length; i <= len; ++i) {
|
|
29
|
+
if (i < len)
|
|
30
|
+
code = path.charCodeAt(i);
|
|
31
|
+
else if (isPathSeparator(code))
|
|
32
|
+
break;
|
|
33
|
+
else
|
|
34
|
+
code = CHAR_FORWARD_SLASH;
|
|
35
|
+
if (isPathSeparator(code)) {
|
|
36
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
37
|
+
// NOOP
|
|
38
|
+
}
|
|
39
|
+
else if (lastSlash !== i - 1 && dots === 2) {
|
|
40
|
+
if (res.length < 2 ||
|
|
41
|
+
lastSegmentLength !== 2 ||
|
|
42
|
+
res.charCodeAt(res.length - 1) !== CHAR_DOT ||
|
|
43
|
+
res.charCodeAt(res.length - 2) !== CHAR_DOT) {
|
|
44
|
+
if (res.length > 2) {
|
|
45
|
+
const lastSlashIndex = res.lastIndexOf(separator);
|
|
46
|
+
if (lastSlashIndex === -1) {
|
|
47
|
+
res = "";
|
|
48
|
+
lastSegmentLength = 0;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
res = res.slice(0, lastSlashIndex);
|
|
52
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
|
|
53
|
+
}
|
|
54
|
+
lastSlash = i;
|
|
55
|
+
dots = 0;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
else if (res.length === 2 || res.length === 1) {
|
|
59
|
+
res = "";
|
|
60
|
+
lastSegmentLength = 0;
|
|
61
|
+
lastSlash = i;
|
|
62
|
+
dots = 0;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (allowAboveRoot) {
|
|
67
|
+
if (res.length > 0)
|
|
68
|
+
res += `${separator}..`;
|
|
69
|
+
else
|
|
70
|
+
res = "..";
|
|
71
|
+
lastSegmentLength = 2;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (res.length > 0)
|
|
76
|
+
res += separator + path.slice(lastSlash + 1, i);
|
|
77
|
+
else
|
|
78
|
+
res = path.slice(lastSlash + 1, i);
|
|
79
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
80
|
+
}
|
|
81
|
+
lastSlash = i;
|
|
82
|
+
dots = 0;
|
|
83
|
+
}
|
|
84
|
+
else if (code === CHAR_DOT && dots !== -1) {
|
|
85
|
+
++dots;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
dots = -1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return res;
|
|
92
|
+
}
|
|
93
|
+
export function _format(sep, pathObject) {
|
|
94
|
+
const dir = pathObject.dir || pathObject.root;
|
|
95
|
+
const base = pathObject.base ||
|
|
96
|
+
(pathObject.name || "") + (pathObject.ext || "");
|
|
97
|
+
if (!dir)
|
|
98
|
+
return base;
|
|
99
|
+
if (base === sep)
|
|
100
|
+
return dir;
|
|
101
|
+
if (dir === pathObject.root)
|
|
102
|
+
return dir + base;
|
|
103
|
+
return dir + sep + base;
|
|
104
|
+
}
|
|
105
|
+
const WHITESPACE_ENCODINGS = {
|
|
106
|
+
"\u0009": "%09",
|
|
107
|
+
"\u000A": "%0A",
|
|
108
|
+
"\u000B": "%0B",
|
|
109
|
+
"\u000C": "%0C",
|
|
110
|
+
"\u000D": "%0D",
|
|
111
|
+
"\u0020": "%20",
|
|
112
|
+
};
|
|
113
|
+
export function encodeWhitespace(string) {
|
|
114
|
+
return string.replaceAll(/[\s]/g, (c) => {
|
|
115
|
+
return WHITESPACE_ENCODINGS[c] ?? c;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
export function lastPathSegment(path, isSep, start = 0) {
|
|
119
|
+
let matchedNonSeparator = false;
|
|
120
|
+
let end = path.length;
|
|
121
|
+
for (let i = path.length - 1; i >= start; --i) {
|
|
122
|
+
if (isSep(path.charCodeAt(i))) {
|
|
123
|
+
if (matchedNonSeparator) {
|
|
124
|
+
start = i + 1;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (!matchedNonSeparator) {
|
|
129
|
+
matchedNonSeparator = true;
|
|
130
|
+
end = i + 1;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return path.slice(start, end);
|
|
134
|
+
}
|
|
135
|
+
export function stripTrailingSeparators(segment, isSep) {
|
|
136
|
+
if (segment.length <= 1) {
|
|
137
|
+
return segment;
|
|
138
|
+
}
|
|
139
|
+
let end = segment.length;
|
|
140
|
+
for (let i = segment.length - 1; i > 0; i--) {
|
|
141
|
+
if (isSep(segment.charCodeAt(i))) {
|
|
142
|
+
end = i;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return segment.slice(0, end);
|
|
149
|
+
}
|
|
150
|
+
export function stripSuffix(name, suffix) {
|
|
151
|
+
if (suffix.length >= name.length) {
|
|
152
|
+
return name;
|
|
153
|
+
}
|
|
154
|
+
const lenDiff = name.length - suffix.length;
|
|
155
|
+
for (let i = suffix.length - 1; i >= 0; --i) {
|
|
156
|
+
if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
|
|
157
|
+
return name;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return name.slice(0, -suffix.length);
|
|
161
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Determines the common path from a set of paths, using an optional separator,
|
|
2
|
+
* which defaults to the OS default separator.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { common } from "https://deno.land/std@$STD_VERSION/path/mod.ts";
|
|
6
|
+
* const p = common([
|
|
7
|
+
* "./deno/std/path/mod.ts",
|
|
8
|
+
* "./deno/std/fs/mod.ts",
|
|
9
|
+
* ]);
|
|
10
|
+
* console.log(p); // "./deno/std/"
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function common(paths: string[], sep?: string): string;
|