Giter Site home page Giter Site logo

get-dev-paths's Introduction

get-dev-paths

Search node_modules for symlinks that resolve to a package outside any node_modules directories.

Returns an array of symlink paths that match the following criteria:

  • they live in node_modules
  • their real paths are not in node_modules
  • they exist in package.json (but not devDependencies)

Every matched package also has its node_modules searched.

Scoped packages are supported.

New in v0.1.1: Up to 50x faster!

import getDevPaths from 'get-dev-paths';

// When called with one argument, an array is returned which contains symlink
// paths that match the required criteria.
let paths = getDevPaths(process.cwd());

// When you want an array of resolved symlinks, set `preserveLinks` to false:
paths = getDevPaths(__dirname, {
  preserveLinks: false,
});

// When the returned array is missing an expected package, you can use the
// `onError` option to inspect why a symlink was skipped.
paths = getDevPaths(__dirname, {
  onError: console.error,
});

get-dev-paths's People

Contributors

aleclarson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

get-dev-paths's Issues

Symlinks seems stopped after update node.

const fs = require('fs')
const getDevPaths = require('get-dev-paths')

const projectRoot = __dirname
module.exports = {
  // Old way
  getProjectRoots: () => Array.from(new Set(
    getDevPaths(projectRoot).map($ => fs.realpathSync($))
  )),
  // New way
  watchFolders: Array.from(new Set(
    getDevPaths(projectRoot).map($ => fs.realpathSync($))
  ))
}

image

node: 11.3.0
metro: 0.50.0

not working, unless add the dependency which you linked in your package.json manually

I am working on a React-Native project, and I need test a package locally, before I publish it. So I need use yarn link

But yarn link does not work well with React-Native, because motro bundler does not support yarn link or npm link.

But I found metro-symlinked-deps, which will work according to its introduction.

So I tried it, but it not work well.

Then I check the metro-symlinked-deps source code, I found out it used this lib to get the linking package's path.

After some dig out, I found the local linking package path will not output unless it's name is in the project package.json

          fs.readdirSync(path.join(depsDir, name)).forEach(function(name) {
            if (deps[name = scope + '/' + name]) {
              return addPath(path.join(depsDir, name));
            }
          });

But seems like yarn link or npm link won't add the linking package name in the package.json

Currently, I add my local package's name in package.json manually. Like this:

"dependencies": {
    "myPackageName" : "*"
},

And it worked ~

I'm not sure whether I'm doing right or not, and the doc does not mention this.

So, could you help me to solve this problem?

Thanks a lot!

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.