Code Monkey home page Code Monkey logo

symlinked's Introduction

symlinked

Node utility to list symlinks made by npm link, yarn link, or fs.link

Install

npm install symlinked

Local install as above is best practice if you are using in a shared codebase because then all developers will use the same version. CLI can be used locally via npx or via npm scripts. npm install has a --global flag you can add if you prefer global use. Yarn can be used via yarn add and yarn global add respectively if you prefer yarn.

CLI

Usage: symlinked <command> [<path>]

  Finds all linked package names of an npm package.

Commands:

  names    Get linked package names
  paths    Get linked package paths
  roots    Get linked package roots
  links    Get linked package links

Options:

  -h, --help     Display this usage info

CLI example

# Link some packages for example
npm link @songkick/promise-retry
npm link eol

$ symlinked names
@songkick/promise-retry
eol

$ symlinked paths
/Users/doe/project/node_modules/@songkick/promise-retry
/Users/doe/project/node_modules/eol

$ symlinked roots
/Users/doe/project/node_modules/@songkick/promise-retry/node_modules
/Users/doe/project/node_modules/eol/node_modules

$ symlinked links
/usr/local/lib/node_modules/@songkick/promise-retry
/usr/local/lib/node_modules/eol

API

require

const symlinked = require("symlinked")

Methods

  • symlinked.names(dir: ".") get array of linked package names
  • symlinked.paths(dir: ".") get array of linked package paths
  • symlinked.roots(dir: ".") get array of linked package roots
  • symlinked.links(dir: ".") get array of linked package links
  • symlinked.is(path) test if path exists and is linked
  • symlinked.read(path) read link

Examples

Ran in package directory with said dependency linked on both ends

symlinked.names()
// [ 'said' ]
symlinked.paths()
// [ '/Users/jdoe/symlinked/node_modules/said' ]
symlinked.roots()
// [ '/Users/jdoe/symlinked/node_modules/said/node_modules' ]
symlinked.links()
// [ '/Users/said' ]

Webpack

resolve.modules configuration to resolve dependencies of linked dependencies

module.exports = {
  resolve: {
    modules: ["node_modules"].concat(symlinked.roots())
  }
}

symlinked's People

Contributors

ryanve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

symlinked's Issues

Binary throws /usr/bin/env: 'node\r': No such file or directory

This is caused by line endings that don't work on other platforms. I assume you are using Windows and this is the problem it is causing:

on Linux:
image

and on Mac:
image

Just forking it to my account and using it from there, ie: yarn add -D https://github.com/emahuni/symlinked fixed the problem because Github removed DOS line endings \r\n. However, the correct solution would be to let the destination decide the line endings to use and by stripping DOS line endings, then publish the package with a new version in npm.

see https://stackoverflow.com/a/67870789/1673161 and https://stackoverflow.com/a/58558771/1673161 for solution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.