mklnks
v2.0.0
Published
Create links as configured.
Downloads
90
Maintainers
Readme
Create links as configured.
API
See also main.d.ts.
function mklnks(options: Options): Promise<LinkInfo[]>;Options
baseDir
Base path for resolving paths.
- Type:
string - Default:
'.'(==process.cwd())
dryRun
Run trial execution without actual link creation.
- Type:
boolean - Default:
false
entries
An object mapping link path to target path.
- Type:
Record<string, string> - Supported link formats:
- absolute/relative path
- Supported target formats:
- absolute/relative path
import:<id>(resolve byimport.meta.resolve)require:<id>(resolve byrequire.resolve)
force
Force to remove existing files/directories in the link path.
- Type:
boolean - Default:
false
noSymlink (Windows only)
Create links with junctions/hard-links instead of symlinks.
- Type:
boolean - Default:
false
Note This option is only available on Windows and ignored on other platforms. On Windows,
mklnkswill automatically fallback to junctions/hard-links if the environment has no permission to create symlinks[^1]. Set this option totrueonly if you want to avoid symlinks explicitly.
[^1]: See here to create/modify symlinks without elevating as administrator on Windows.
quiet
Not to display logs.
- Type:
boolean - Default: The value of
silent
silent
Not to display logs & warnings.
- Type:
boolean - Default:
false
LinkInfo
mklnks returns a Promise that resolves to an array of LinkInfo.
LinkInfo has the following properties.
| Name | Type | Description |
| ------------ | --------- | ----------------------------------------------------------------------------------------------------------------- |
| dryRun | boolean | true if run with Options.dryRun: true |
| isAnyLink | boolean | true if any link has created. false if otherwise(e.g. linkPath & targetPath refer to same location). |
| isDirLink | boolean | true if the link created is directory link. |
| isFileLink | boolean | true if the link created is file link. |
| isHardLink | boolean | true if the link created is hard-link. |
| isJunction | boolean | true if the link created is junction. |
| isSoftLink | boolean | true if the link created is soft-link (junction or symlink). |
| isSymLink | boolean | true if the link created is symlink. |
| linkPath | string | The path of link source. |
| targetPath | string | The path of link tareget. |
CLI
See also mklnks --help output.
USAGE:
$ mklnks [FLAGS]
FLAGS:
-a, --available Check if symlinks are available (for Windows).
-c, --config <FILE> Run with isolated config file (*.{json|js|cjs|mjs}).
-d, --dry-run Run trial execution without actual link creation.
(Override `Options.dryRun` to `true`.)
-f, --force Force to remove existing files/directories in the link path.
(Override `Options.force` to `true`.)
-h, --help Display this message.
-q, --quiet NOT to display logs.
(Override `Options.quiet` to `true`.)
-s, --silent NOT to display logs & warnings.
(Override `Options.silent` to `true`.)
-v, --version Display version number.
By default, load "mklnks" field in `package.json` as configurations.Configurations
with current package.json
{
"name": "your-package-name",
"description": "...",
"version": "...",
...,
"mklnks": {
// mklnks options
"entries": {
"path/to/link1": "path/to/target1",
"path/to/link2": "import:some-exported-id",
"path/to/link3": "require:some-exported-id",
...
}
},
}with isolated config file (*.{json|js|cjs|mjs})
specify with
-cflag
- JSON style (
*.json){ "entries": { "path/to/link1": "path/to/target1", "path/to/link2": "import:some-exported-id", "path/to/link3": "require:some-exported-id", ... } } - CommonJS style (
*.js/*.cjs)module.exports = { entries: { 'path/to/link1': 'path/to/target1', 'path/to/link2': 'import:some-exported-id', 'path/to/link3': 'require:some-exported-id', ... }, }; - ECMAScript style (
*.js/*.mjs)export default { entries: { 'path/to/link1': 'path/to/target1', 'path/to/link2': 'import:some-exported-id', 'path/to/link3': 'require:some-exported-id', ... }, };
