npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mklnks

v2.0.0

Published

Create links as configured.

Downloads

407

Readme

Create links as configured.

npm downloads install size license node types vulnerabilities CodeQL


API

See also main.d.ts.

function mklnks(options: Options): Promise<LinkInfo[]>;

Options

baseDir

Base path for resolving paths.

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:

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, mklnks will automatically fallback to junctions/hard-links if the environment has no permission to create symlinks[^1]. Set this option to true only 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 -c flag

  • 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',
            ...
        },
    };