Socket
Socket
Sign inDemoInstall

react-native-cli

Package Overview
Dependencies
Maintainers
6
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-cli - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

CONTRIBUTING.md

72

index.js

@@ -7,6 +7,9 @@ #!/usr/bin/env node

'use strict';
var fs = require('fs');
var path = require('path');
var exec = require('child_process').exec;
var spawn = require('child_process').spawn;
var prompt = require("prompt");
var prompt = require('prompt');

@@ -18,10 +21,13 @@ var CLI_MODULE_PATH = function() {

'react-native',
'cli'
'cli.js'
);
};
checkForVersionArgument();
var cli;
try {
cli = require(CLI_MODULE_PATH());
} catch(e) {}
var cliPath = CLI_MODULE_PATH();
if (fs.existsSync(cliPath)) {
cli = require(cliPath);
}

@@ -42,6 +48,7 @@ if (cli) {

if (args[1]) {
init(args[1]);
var verbose = process.argv.indexOf('--verbose') >= 0;
init(args[1], verbose);
} else {
console.error(
'Usage: react-native init <ProjectName>'
'Usage: react-native init <ProjectName> [--verbose]'
);

@@ -82,13 +89,13 @@ process.exit(1);

function init(name) {
function init(name, verbose) {
validatePackageName(name);
if (fs.existsSync(name)) {
createAfterConfirmation(name)
createAfterConfirmation(name, verbose);
} else {
createProject(name);
createProject(name, verbose);
}
}
function createAfterConfirmation(name) {
function createAfterConfirmation(name, verbose) {
prompt.start();

@@ -106,3 +113,3 @@

if (result.yesno[0] === 'y') {
createProject(name);
createProject(name, verbose);
} else {

@@ -115,3 +122,3 @@ console.log('Project initialization canceled');

function createProject(name) {
function createProject(name, verbose) {
var root = path.resolve(name);

@@ -140,4 +147,16 @@ var projectName = path.basename(root);

run('npm install --save react-native', function(e) {
console.log('Installing react-native package from npm...');
if (verbose) {
runVerbose(root, projectName);
} else {
run(root, projectName);
}
}
function run(root, projectName) {
exec('npm install --save react-native', function(e, stdout, stderr) {
if (e) {
console.log(stdout);
console.error(stderr);
console.error('`npm install --save react-native` failed');

@@ -152,14 +171,21 @@ process.exit(1);

function run(command, cb) {
var parts = command.split(/\s+/);
var cmd = parts[0];
var args = parts.slice(1);
var proc = spawn(cmd, args, {stdio: 'inherit'});
proc.on('close', function(code) {
function runVerbose(root, projectName) {
var proc = spawn('npm', ['install', '--verbose', '--save', 'react-native'], {stdio: 'inherit'});
proc.on('close', function (code) {
if (code !== 0) {
cb(new Error('Command exited with a non-zero status'));
} else {
cb(null);
console.error('`npm install --save react-native` failed');
return;
}
cli = require(CLI_MODULE_PATH());
cli.init(root, projectName);
});
}
function checkForVersionArgument() {
if (process.argv.indexOf('-v') >= 0 || process.argv.indexOf('--version') >= 0) {
var pjson = require('./package.json');
console.log(pjson.version);
process.exit();
}
}
{
"name": "react-native-cli",
"version": "0.1.4",
"version": "0.1.5",
"description": "The ReactNative cli tools",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"bin": {

@@ -7,0 +10,0 @@ "react-native": "index.js"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc