UNPKG

1.85 kBMarkdownView Raw
1# pkg-reflector
2
3[![Build Status](https://img.shields.io/circleci/project/zcong1993/pkg-reflector/master.svg?style=flat)](https://circleci.com/gh/zcong1993/pkg-reflector) [![NPM version](https://img.shields.io/npm/v/pkg-reflector.svg?style=flat-square)](https://npmjs.com/package/pkg-reflector) [![npm](https://img.shields.io/npm/dm/pkg-reflector.svg)](https://www.npmjs.com/package/pkg-reflector)
4
5> Find and install the npm modules your js files used
6
7
8---
9
10## New
11
12- support alias `prf` for `pkg-reflector`
13
14- now support multi files, can be used like `pkg-reflector src/* libs/* *.js`, resolve files using [globby](https://github.com/sindresorhus/globby) and always ignore `**/node_modules/**`
15
16## Install
17
18```sh
19$ npm install -g pkg-reflector
20# using yarn
21$ yarn global add pkg-reflector
22```
23
24## Feature
25
26Sometimes, you copy some js file from other folder or project, such as `rollup.config.js`,you only want to use it in your current project.
27
28If the js file depends some pkgs, you should install the pkgs first by your self, like this:
29
30```sh
31$ yarn add pkg1 pkg2 pkg3...
32```
33
34you always get some error when add pkgs cause wrong spelling of the long pkg name, so use `pkg-reflector`, you can do it like this:
35
36```sh
37$ pkg-reflector foo.js
38# then have a coffee
39```
40
41easy way, isn't it ?
42
43- automatic ignore the pkgs your `package.json` exist
44- automatic ignore node core modules
45- ignore local file, such as `./index.js`
46- correct parse `foo/bar` pkgs
47- can only install es5 modules, es6 modules or all of them
48
49## Usage
50```sh
51$ pkg-reflector <js file[s]> [options]
52```
53
54### simple
55```sh
56$ pkg-reflector <file>
57```
58
59
60will install the pkgs and save `dependence`.
61
62### multi files
63
64```sh
65$ pkg-reflector file1 file2 ...
66```
67
68or use `patterns` all [sindresorhus/globby](https://github.com/sindresorhus/globby) support
69
70```sh
71$ pkg-reflector ./*
72```