path-run

0.1.0 • Public • Published

path-run Build Status codecov explain

esay change you require paths Now

中文 | english

如果改变, 一个文件的位置, 那么相对应, 其他文件对这个文件的引用修改就是个问题

你可以试试 path-run, 改动你的文件位置不那么手动

Install

npm install --global path-run

正确做法使用-Cli

  1. 复制文件到目的地
- demo
    - index.js
    - input
        - input1.js
        - input2.js
    - output
        - output1.js
        - output2.js
- demo
    - index.js
    - input
        - ✂️input1.js // <===== copy to output
        - input2.js
    - output
        - ➕output3.js // <===== from input/input1.js
        - output1.js
        - output2.js
  1. 运行 cli
path-run demo/input/input1.js demo/output/output3.js
# path-run [input] [output]
 

1⃣️process.cwd() 下所有引用 input 的 路径 都会变为 output 2⃣️ output 的 文件 下, 导入相对文件正确导入

  1. 移除 input1.js
- demo
    - index.js
    - input
                    <===== ✂️cut
        - input2.js
    - output
        - output3.js // <===== from input/input1.js
        - output1.js
        - output2.js

真实项目-transltemds

命令行实例

demo-cli-show

输入与输出文件的变化

inpath-diff-outpath

其他导入文件变化

index-diff


警告⚠️ , path-run 不会 改变 package.json main 或 bin 字段, 请自行修正


API

pathRun({options})

options

1. InPath

Type: string

Abs Path

2. OutPath

Type: string

Abs Path

3. cwd

Type: string

default : process.cwd()

return

Type: Array

数组中每个值像这样

const options = {
  files: 'path/to/file',
  from: /foo/g,
  to: 'bar',
};

replace-in-file 使用

https://github.com/adamreisnz/replace-in-file

CLI

npm install --global path-run
  esay change you require paths Now

  Usage
    $ path-run [input] [output]

  Options
        input  要更改的路径
        output 变成的路径

  Examples
        $ path-run './index' './lib/index'

  will change all process.cwd()/* files require Path 'index' => './lib/index'

联系

nodepaths js 模块描述

License

MIT © chinanf-boy

Readme

Keywords

Package Sidebar

Install

npm i path-run

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

12 kB

Total Files

6

Last publish

Collaborators

  • yobrave1995