@reliverse/pathkit 1.2.1 → 1.2.3
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/README.md +42 -42
- package/bin/mod.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -283,6 +283,48 @@ Features:
|
|
|
283
283
|
- 📝 Detailed change logging
|
|
284
284
|
- 🎨 Supports custom aliases
|
|
285
285
|
|
|
286
|
+
### Path Segment Manipulation
|
|
287
|
+
|
|
288
|
+
Manipulate path segments in import statements:
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
import {
|
|
292
|
+
stripPathSegments,
|
|
293
|
+
stripPathSegmentsInDirectory,
|
|
294
|
+
attachPathSegments,
|
|
295
|
+
attachPathSegmentsInDirectory
|
|
296
|
+
} from "@reliverse/pathkit";
|
|
297
|
+
|
|
298
|
+
// Strip segments from a path
|
|
299
|
+
stripPathSegments("src/components/Button.tsx", 1); // "components/Button.tsx"
|
|
300
|
+
|
|
301
|
+
// Strip segments from imports in a directory
|
|
302
|
+
await stripPathSegmentsInDirectory({
|
|
303
|
+
targetDir: "./src",
|
|
304
|
+
segmentsToStrip: 1,
|
|
305
|
+
alias: "@" // Optional: preserve alias prefix
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// Attach segments to a path
|
|
309
|
+
attachPathSegments("Button.tsx", "components", {
|
|
310
|
+
position: "before", // "before" | "after"
|
|
311
|
+
normalize: true, // Normalize the path
|
|
312
|
+
ensureSlash: true, // Ensure slash between segments
|
|
313
|
+
preserveRoot: true, // Preserve root in absolute paths
|
|
314
|
+
preserveAlias: "@" // Optional: preserve alias prefix
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// Attach segments to imports in a directory
|
|
318
|
+
await attachPathSegmentsInDirectory({
|
|
319
|
+
targetDir: "./src",
|
|
320
|
+
segments: "components",
|
|
321
|
+
options: {
|
|
322
|
+
position: "before",
|
|
323
|
+
preserveAlias: "@"
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
```
|
|
327
|
+
|
|
286
328
|
### Alias Resolution
|
|
287
329
|
|
|
288
330
|
Advanced alias handling and resolution:
|
|
@@ -466,45 +508,3 @@ Bug reports & PRs are warmly welcome—come on in!
|
|
|
466
508
|
[](https://npmjs.com/package/@reliverse/pathkit)
|
|
467
509
|
[](https://github.com/reliverse/pathkit)
|
|
468
510
|
[](LICENSE)
|
|
469
|
-
|
|
470
|
-
### Path Segment Manipulation
|
|
471
|
-
|
|
472
|
-
Manipulate path segments in import statements:
|
|
473
|
-
|
|
474
|
-
```ts
|
|
475
|
-
import {
|
|
476
|
-
stripPathSegments,
|
|
477
|
-
stripPathSegmentsInDirectory,
|
|
478
|
-
attachPathSegments,
|
|
479
|
-
attachPathSegmentsInDirectory
|
|
480
|
-
} from "@reliverse/pathkit";
|
|
481
|
-
|
|
482
|
-
// Strip segments from a path
|
|
483
|
-
stripPathSegments("src/components/Button.tsx", 1); // "components/Button.tsx"
|
|
484
|
-
|
|
485
|
-
// Strip segments from imports in a directory
|
|
486
|
-
await stripPathSegmentsInDirectory({
|
|
487
|
-
targetDir: "./src",
|
|
488
|
-
segmentsToStrip: 1,
|
|
489
|
-
alias: "@" // Optional: preserve alias prefix
|
|
490
|
-
});
|
|
491
|
-
|
|
492
|
-
// Attach segments to a path
|
|
493
|
-
attachPathSegments("Button.tsx", "components", {
|
|
494
|
-
position: "before", // "before" | "after"
|
|
495
|
-
normalize: true, // Normalize the path
|
|
496
|
-
ensureSlash: true, // Ensure slash between segments
|
|
497
|
-
preserveRoot: true, // Preserve root in absolute paths
|
|
498
|
-
preserveAlias: "@" // Optional: preserve alias prefix
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
// Attach segments to imports in a directory
|
|
502
|
-
await attachPathSegmentsInDirectory({
|
|
503
|
-
targetDir: "./src",
|
|
504
|
-
segments: "components",
|
|
505
|
-
options: {
|
|
506
|
-
position: "before",
|
|
507
|
-
preserveAlias: "@"
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
```
|
package/bin/mod.js
CHANGED
|
@@ -15,7 +15,7 @@ const logInternal = (msg) => {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
const DEBUG_MODE = false;
|
|
18
|
-
const EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
18
|
+
const EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".d.ts"];
|
|
19
19
|
const SLASH = "/";
|
|
20
20
|
const BACK_SLASH = "\\";
|
|
21
21
|
const DOT = ".";
|