Skip to content

Commit

Permalink
Fix few paths for react-native cli scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
frantic committed Mar 22, 2015
1 parent df73a48 commit 4d077f4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function run() {
// Here goes any cli commands we need to
}

function init() {
spawn('sh', [path.resolve(__dirname, 'init.sh')], {stdio:'inherit'});
function init(root, projectName) {
spawn(path.resolve(__dirname, 'init.sh'), [projectName], {stdio:'inherit'});
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion packager/init.sh → init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def cp(src, dest, app_name)
end

def main(dest, app_name)
source = File.expand_path("../../Examples/SampleApp", __FILE__)
source = File.expand_path("../Examples/SampleApp", __FILE__)
files = Dir.chdir(source) { Dir["**/*"] }
.reject { |file| file["project.xcworkspace"] || file["xcuserdata"] }
.each { |file|
Expand Down
23 changes: 14 additions & 9 deletions react-native-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;

var CLI_MODULE_PATH = path.resolve(
process.cwd(),
'node_modules',
'react-native',
'cli'
);
var CLI_MODULE_PATH = function() {
return path.resolve(
process.cwd(),
'node_modules',
'react-native',
'cli'
);
};

var cli;
try {
cli = require(CLI_MODULE_PATH);
cli = require(CLI_MODULE_PATH());
} catch(e) {}

if (cli) {
Expand Down Expand Up @@ -66,7 +68,10 @@ function init(name) {
var packageJson = {
name: projectName,
version: '0.0.1',
private: true
private: true,
scripts: {
start: "react-native start"
}
};
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify(packageJson));
process.chdir(root);
Expand All @@ -77,7 +82,7 @@ function init(name) {
process.exit(1);
}

var cli = require(CLI_MODULE_PATH);
var cli = require(CLI_MODULE_PATH());
cli.init(root, projectName);
});
}
Expand Down

0 comments on commit 4d077f4

Please sign in to comment.