xgqfrms-GitHub / Node-CLI-Tools

一个 Node.js CLI 工具,查看指定 git 仓库的 commit history ; 能对 commit history 进行搜索; 能查看指定时间范围的 commit history.
https://node-cli-tools.xgqfrms.xyz
MIT License
6 stars 2 forks source link

npm link #8

Closed xgqfrms-GitHub closed 7 years ago

xgqfrms-GitHub commented 7 years ago

https://github.com/xgqfrms-GitHub/Node-CLI-Tools/wiki/npm-link


# npm link <module-name>
$ npm link nct
xgqfrms-GitHub commented 7 years ago

npm link <module-name>

https://60devs.com/simple-way-to-manage-local-node-module-using-npm-link.html

https://egghead.io/lessons/node-js-using-npm-link-to-use-node-modules-that-are-in-progress

https://www.sitepoint.com/using-npm-link-node-js/

https://youtu.be/nKFe1lhGSk0

https://stackoverflow.com/questions/42368901/how-to-execute-npm-link-directly-on-install

http://codetunnel.io/you-can-finally-npm-link-packages-that-contain-peer-dependencies/

xgqfrms-GitHub commented 7 years ago

commits & npm link

https://github.com/xgqfrms/learning/commits/gh-pages

https://github.com/xgqfrms/learning/commit/047ea752015316da40fa8cb239aa8226053976d5

 {
      "name": "hello",            "name": "hello",
      "bin": {            "bin": {
 -        "hello": "hello"       +        "hi": "hello",
 +        "nc": "nodecli"
 +    },
 +    "dependencies": {
 +        "commander": "^2.9.0"
      }           }
  }       }

npm link

https://github.com/xgqfrms-GitHub/Node-CLI-Tools/issues/2

https://medium.freecodecamp.com/writing-command-line-applications-in-nodejs-2cf8327eee2

https://www.jonathanfielding.com/cli-tool-using-node/

We now simply need to return to our console and run npm link which will install the CLI tool on our machine. 我们现在只需要返回到我们的控制台,并运行npm链接,这将在我们的机器上安装CLI工具。

https://github.com/tj/commander.js/tree/master/examples

Node.js CLI & -rwxr-xr-x 755 权限

https://github.com/xgqfrms/learning/commit/0fdff6d0c19e457b07843c4f3a280fd0e7f9b647

xgqfrms-GitHub commented 7 years ago

npm link error ???

cmd-chmod-755-ok ncl-ok nct-name-conflict npm link error node-fetch sudo 755 cmd

xgqfrms-GitHub commented 7 years ago

C:\Users\xray\AppData\Roaming\npm-cache_logs\2017-06-11T18_24_42_614Z-debug.log

xgqfrms-GitHub commented 7 years ago
0 info it worked if it ends with ok
1 verbose cli [ 'H:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\xray\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'link' ]
2 info using npm@5.0.2
3 info using node@v6.10.3
4 verbose linkPkg G:\wwwRoot\learning\JavaScript\Ajax\js\node-cli-tools\nct
5 verbose link build target C:\Users\xray\AppData\Roaming\npm\node_modules\node-cli-tools
6 silly install runPreinstallTopLevelLifecycles
7 silly preinstall node-cli-tools@1.1.1
8 info lifecycle node-cli-tools@1.1.1~preinstall: node-cli-tools@1.1.1
9 silly lifecycle node-cli-tools@1.1.1~preinstall: no script for preinstall, continuing
10 silly install loadCurrentTree
11 silly install readLocalPackageData
12 silly install loadIdealTree
13 silly install cloneCurrentTreeToIdealTree
14 silly install loadShrinkwrap
15 silly install loadAllDepsIntoIdealTree
16 silly currentTree node-cli-tools@1.1.1
16 silly currentTree +-- colors@1.1.2
16 silly currentTree +-- encoding@0.1.12
16 silly currentTree +-- iconv-lite@0.4.17
16 silly currentTree +-- is-stream@1.1.0
16 silly currentTree `-- node-fetch@1.7.1
17 silly idealTree node-cli-tools@1.1.1
17 silly idealTree +-- colors@1.1.2
17 silly idealTree +-- encoding@0.1.12
17 silly idealTree +-- iconv-lite@0.4.17
17 silly idealTree +-- is-stream@1.1.0
17 silly idealTree `-- node-fetch@1.7.1
18 silly install generateActionsToTake
19 silly diffTrees action count 0
20 silly decomposeActions action count 0
21 silly install executeActions
22 silly doSerial global-install 0
23 verbose correctMkdir C:\Users\xray\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing
24 verbose lock using C:\Users\xray\AppData\Roaming\npm-cache\_locks\staging-8352da5f179cc946.lock for G:\wwwRoot\learning\JavaScript\Ajax\js\node-cli-tools\nct\node_modules\.staging
25 silly doParallel extract 0
26 silly doReverseSerial remove 0
27 silly doSerial move 0
28 silly doSerial finalize 0
29 silly doParallel refresh-package-json 0
30 silly doParallel preinstall 0
31 silly doSerial build 0
32 silly doSerial global-link 0
33 silly doParallel update-linked 0
34 silly doSerial install 0
35 silly doSerial postinstall 0
36 verbose unlock done using C:\Users\xray\AppData\Roaming\npm-cache\_locks\staging-8352da5f179cc946.lock for G:\wwwRoot\learning\JavaScript\Ajax\js\node-cli-tools\nct\node_modules\.staging
37 silly install runPostinstallTopLevelLifecycles
38 silly build node-cli-tools@1.1.1
39 info linkStuff node-cli-tools@1.1.1
40 silly linkStuff node-cli-tools@1.1.1 has G:\wwwRoot\learning\JavaScript\Ajax\js\node-cli-tools as its parent node_modules
41 verbose linkBins node-cli-tools@1.1.1
42 verbose linkMans node-cli-tools@1.1.1
43 silly install node-cli-tools@1.1.1
44 info lifecycle node-cli-tools@1.1.1~install: node-cli-tools@1.1.1
45 silly lifecycle node-cli-tools@1.1.1~install: no script for install, continuing
46 silly postinstall node-cli-tools@1.1.1
47 info lifecycle node-cli-tools@1.1.1~postinstall: node-cli-tools@1.1.1
48 silly lifecycle node-cli-tools@1.1.1~postinstall: no script for postinstall, continuing
49 silly prepublish node-cli-tools@1.1.1
50 info lifecycle node-cli-tools@1.1.1~prepublish: node-cli-tools@1.1.1
51 silly lifecycle node-cli-tools@1.1.1~prepublish: no script for prepublish, continuing
52 info lifecycle node-cli-tools@1.1.1~prepare: node-cli-tools@1.1.1
53 silly lifecycle node-cli-tools@1.1.1~prepare: no script for prepare, continuing
54 silly install saveToDependencies
55 verbose saving []
56 info lifecycle undefined~preshrinkwrap: undefined
57 silly lifecycle undefined~preshrinkwrap: no script for preshrinkwrap, continuing
58 info lifecycle undefined~shrinkwrap: undefined
59 silly lifecycle undefined~shrinkwrap: no script for shrinkwrap, continuing
60 info lifecycle undefined~postshrinkwrap: undefined
61 silly lifecycle undefined~postshrinkwrap: no script for postshrinkwrap, continuing
62 silly install printInstalled
63 info build C:\Users\xray\AppData\Roaming\npm\node_modules\node-cli-tools
64 info linkStuff node-cli-tools@1.1.1
65 silly linkStuff node-cli-tools@1.1.1 has C:\Users\xray\AppData\Roaming\npm\node_modules as its parent node_modules
66 silly linkStuff node-cli-tools@1.1.1 is part of a global install
67 silly linkStuff node-cli-tools@1.1.1 is installed into a global node_modules
68 silly linkStuff node-cli-tools@1.1.1 is installed into the top-level global node_modules
69 verbose linkBins node-cli-tools@1.1.1
70 verbose linkBins [ { xnct: 'nctcli' },
70 verbose linkBins   'C:\\Users\\xray\\AppData\\Roaming\\npm',
70 verbose linkBins   true ]
71 verbose linkMans node-cli-tools@1.1.1
72 verbose stack Error: ENOENT: no such file or directory, chmod 'C:\Users\xray\AppData\Roaming\npm\node_modules\node-cli-tools\nctcli'
72 verbose stack     at Error (native)
73 verbose cwd G:\wwwRoot\learning\JavaScript\Ajax\js\node-cli-tools\nct
74 verbose Windows_NT 10.0.14393
75 verbose argv "H:\\Program Files\\nodejs\\node.exe" "C:\\Users\\xray\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "link"
76 verbose node v6.10.3
77 verbose npm  v5.0.2
78 error path C:\Users\xray\AppData\Roaming\npm\node_modules\node-cli-tools\nctcli
79 error code ENOENT
80 error errno -4058
81 error syscall chmod
82 error enoent ENOENT: no such file or directory, chmod 'C:\Users\xray\AppData\Roaming\npm\node_modules\node-cli-tools\nctcli'
83 error enoent This is related to npm not being able to find a file.
84 verbose exit [ -4058, true ]
xgqfrms-GitHub commented 7 years ago

npm link nct name must equal to bin file name with extented.png

nctcli !== nctcli.js

"xnct": "nctcli"

nct name must equal to bin file name with extent

extended file attributes & 扩展文件属性

https://en.wikipedia.org/wiki/Extended_file_attributes

https://zh.wikipedia.org/wiki/%E6%89%A9%E5%B1%95%E6%96%87%E4%BB%B6%E5%B1%9E%E6%80%A7

xgqfrms-GitHub commented 7 years ago

test OK

xnct-ok

xnct-params-ok

xgqfrms-GitHub commented 7 years ago

#!/usr/bin/env node


#!/usr/bin/env node

https://github.com/xgqfrms-GitHub/Node-CLI-Tools/issues/9

xgqfrms-GitHub commented 7 years ago

npm link

just need #!/usr/bin/env node

it doesn't matter with the .extended file name!

usr-bin-env node usr-bin-env node no matter extended

xgqfrms-GitHub commented 7 years ago

https://github.com/xgqfrms-GitHub/Node-CLI-Tools/wiki/npm-link