Socket
Socket
Sign inDemoInstall

react-native-cli

Package Overview
Dependencies
Maintainers
4
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.3 to 0.1.4

54

index.js

@@ -10,2 +10,3 @@ #!/usr/bin/env node

var spawn = require('child_process').spawn;
var prompt = require("prompt");

@@ -37,3 +38,4 @@ var CLI_MODULE_PATH = function() {

if (args[0] === 'init') {
switch (args[0]) {
case 'init':
if (args[1]) {

@@ -47,5 +49,6 @@ init(args[1]);

}
} else {
break;
default:
console.error(
'Command `%s` unrecognized.' +
'Command `%s` unrecognized. ' +
'Did you mean to run this inside a react-native project?',

@@ -55,6 +58,7 @@ args[0]

process.exit(1);
break;
}
}
function init(name) {
function validatePackageName(name) {
if (!name.match(/^[$A-Z_][0-9A-Z_$]*$/i)) {

@@ -69,2 +73,44 @@ console.error(

if (name === 'React') {
console.error(
'"%s" is not a valid name for a project. Please do not use the ' +
'reserved word "React".',
name
);
process.exit(1);
}
}
function init(name) {
validatePackageName(name);
if (fs.existsSync(name)) {
createAfterConfirmation(name)
} else {
createProject(name);
}
}
function createAfterConfirmation(name) {
prompt.start();
var property = {
name: 'yesno',
message: 'Directory ' + name + ' already exist. Continue?',
validator: /y[es]*|n[o]?/,
warning: 'Must respond yes or no',
default: 'no'
};
prompt.get(property, function (err, result) {
if (result.yesno[0] === 'y') {
createProject(name);
} else {
console.log('Project initialization canceled');
process.exit();
}
});
}
function createProject(name) {
var root = path.resolve(name);

@@ -71,0 +117,0 @@ var projectName = path.basename(root);

5

package.json
{
"name": "react-native-cli",
"version": "0.1.3",
"version": "0.1.4",
"description": "The ReactNative cli tools",

@@ -8,3 +8,6 @@ "main": "index.js",

"react-native": "index.js"
},
"dependencies": {
"prompt": "^0.2.14"
}
}
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