1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-08 08:05:14 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
tdzl2003
2016-02-23 00:36:23 +08:00
parent 8bc608581c
commit 56495062c4
16 changed files with 254 additions and 63 deletions

53
react-native-pushy-cli/src/cli.js vendored Executable file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env node
/**
* Created by tdzl2003 on 2/13/16.
*/
import * as path from 'path';
import * as fs from 'fs-promise';
const CLI_MODULE_PATH = function() {
return path.resolve(
process.cwd(),
'node_modules',
'react-native-pushy',
'local-cli'
);
};
const PACKAGE_JSON_PATH = function() {
return path.resolve(
process.cwd(),
'node_modules',
'react-native-pushy',
'package.json'
);
};
checkForVersionCommand();
let cli;
const cliPath = CLI_MODULE_PATH();
if (fs.existsSync(cliPath)) {
cli = require(cliPath);
}
if (cli) {
cli.run();
} else {
console.error('Are you at home directory of a react-native project?');
console.error('`pushy install` is under development, please run `npm install react-native-pushy` to install pushy manually.');
process.exit(1);
}
function checkForVersionCommand() {
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
console.log('react-native-pushy-cli: ' + require('../package.json').version);
try {
console.log('react-native-pushy: ' + require(PACKAGE_JSON_PATH()).version);
} catch (e) {
console.log('react-native-pushy: n/a - not inside a React Native project directory')
}
process.exit();
}
}