-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
130 lines (109 loc) · 3.71 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// /*
// * @Description:
// * @Date: 2020-07-13 23:48:15
// */
// const config = require('libnpmconfig');
// console.log(
// 'configured registry:',
// config.read({
// registry: 'https://default.registry/',
// })
// );
/**
*
* configured registry: FiggyPudding {
cache: '/Users/liyang/.npm',
registry: 'https://default.registry/',
'init-author-name': '李阳',
'//f.pr.meijian.tech/:_authToken': 'ZpkakEouTxviP4Ougx9ITQ==',
home: 'http://cnpmjs.org',
configNames: [ 'npmrc', '.npmrc' ],
envPrefix: /^npm_config_/i,
cwd: '/Users/liyang/code/gitDemo/vscode-versionlens-master',
globalconfig: '/Users/liyang/.nvm/versions/node/v12.8.0/etc/npmrc',
userconfig: '/Users/liyang/.npmrc'
}
*/
// const promiseSpawn = require('@npmcli/promise-spawn')
// promiseSpawn('ls', [ '-laF', 'some/dir/*.js' ], {
// cwd: '/tmp/some/path', // defaults to process.cwd()
// stdioString: false, // stdout/stderr as strings rather than buffers
// stdio: 'pipe', // any node spawn stdio arg is valid here
// // any other arguments to node child_process.spawn can go here as well,
// // but uid/gid will be ignored and set by infer-owner if relevant.
// }, {
// extra: 'things',
// to: 'decorate',
// the: 'result',
// }).then(result => {
// // {code === 0, signal === null, stdout, stderr, and all the extras}
// console.log('ok!', result)
// }).catch(er => {
// // er has all the same properties as the result, set appropriately
// console.error('failed!', er)
// })
// var assert = require("assert")
// var npa = require("npm-package-arg")
// // Pass in the descriptor, and it'll return an object
// try {
// var parsed = npa("@bar/[email protected]")
// console.log(`parsed`, parsed);
// } catch (ex) {
// }
// const ncu = require('npm-check-updates');
// const getVersion = async () => {
// const data = await ncu.run({
// // Any command-line option can be specified here.
// // These are set by default:
// configFilePath: '/Users/liyang/code/github/vscode-npm-manage/package.json',
// jsonUpgraded: true,
// packageManager: 'npm',
// silent: true,
// });
// console.log('data:', data);
// };
// getVersion();
// ncu
// .run({
// // Any command-line option can be specified here.
// // These are set by default:
// jsonUpgraded: true,
// packageManager: 'npm',
// silent: true,
// })
// .then((upgraded) => {
// console.log('dependencies to upgrade:', upgraded);
// });
// const latestVersion = require('latest-version');
// (async () => {
// console.log(await latestVersion('react'));
// console.log(await latestVersion('redux'));
// //=> '0.18.0'
// console.log(await latestVersion('lodash'));
// //=> '1.0.1'
// // Also works with semver ranges and dist-tags
// console.log(await latestVersion('npm', { version: 'latest-3' }));
// //=> '5.5.1'
// })();
// const packageJson = require('package-json');
// (async () => {
// console.log(await packageJson('shuqu-cli'));
// //=> {name: 'ava', ...}
// // Also works with scoped packages
// console.log(await packageJson('nestjs'));
// })();
// var readJson = require('read-package-json');
// // readJson(filename, [logFunction=noop], [strict=false], cb)
// readJson('/Users/liyang/code/github/vscode-npm-manage/package.json', console.error, false, function (er, data) {
// if (er) {
// console.error('There was an error reading the file');
// return;
// }
// console.error('the package data is', data);
// });
// const npmCheck = require('npm-check');
// npmCheck({}).then((currentState) => console.log(currentState.get('packages')));
const request = require('request');
request.get('https://registry.yarnpkg.com/shuqu-cli').on('response', function (response) {
console.log(response); // 200
});