Add capacitorjs runtime
This commit is contained in:
parent
d0ece489ee
commit
f90c0e6c40
8362 changed files with 1502407 additions and 1 deletions
77
node_modules/get-pkg-repo/src/cli.js
generated
vendored
Executable file
77
node_modules/get-pkg-repo/src/cli.js
generated
vendored
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require(`fs`);
|
||||
const getPkgRepo = require(`../`);
|
||||
const through = require(`through2`);
|
||||
const util = require(`util`);
|
||||
|
||||
const yargs = require('yargs/yargs')(process.argv.slice(2))
|
||||
.usage(
|
||||
'\nPractice writing repository URL or validate the repository in a package.json file. If used without specifying a package.json file path, you will enter an interactive shell. Otherwise, the repository info in package.json is printed.'
|
||||
)
|
||||
.scriptName('get-pkg-repo')
|
||||
.command('$0')
|
||||
.command('<path> [<path> ...]')
|
||||
.example('get-pkg-repo')
|
||||
.example('get-pkg-repo package.json')
|
||||
.example('cat package.json | get-pkg-repo')
|
||||
.help().argv;
|
||||
|
||||
const input = yargs._;
|
||||
|
||||
if (process.stdin.isTTY) {
|
||||
if (input.length > 0) {
|
||||
input.forEach(path => {
|
||||
let repo;
|
||||
fs.readFile(path, 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
repo = getPkgRepo(JSON.parse(data));
|
||||
console.log(repo);
|
||||
} catch (e) {
|
||||
console.error(`${path}: ${e.toString()}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
process.stdin
|
||||
.pipe(
|
||||
through.obj((chunk, enc, cb) => {
|
||||
let repo;
|
||||
const pkgData = {
|
||||
repository: chunk.toString(),
|
||||
};
|
||||
|
||||
try {
|
||||
repo = getPkgRepo(pkgData);
|
||||
cb(null, util.format(repo) + '\n');
|
||||
} catch (e) {
|
||||
console.error(e.toString());
|
||||
cb();
|
||||
}
|
||||
})
|
||||
)
|
||||
.pipe(process.stdout);
|
||||
}
|
||||
} else {
|
||||
process.stdin
|
||||
.pipe(
|
||||
through.obj((chunk, enc, cb) => {
|
||||
let repo;
|
||||
try {
|
||||
repo = getPkgRepo(JSON.parse(chunk.toString()));
|
||||
} catch (e) {
|
||||
console.error(e.toString());
|
||||
process.exit(1);
|
||||
}
|
||||
cb(null, util.format(repo) + '\n');
|
||||
})
|
||||
)
|
||||
.pipe(process.stdout);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue