From 52e7b8053f04245fcd90d8847befe3579573276f Mon Sep 17 00:00:00 2001 From: Joe Stanton Date: Thu, 14 May 2015 15:35:09 +0100 Subject: [PATCH] Linked with new local-cli, refactored --- init.js | 23 ++++++----------------- local-cli/cli.js | 6 ++---- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/init.js b/init.js index 423d4211692e00..1d26d52d5e751d 100755 --- a/init.js +++ b/init.js @@ -19,13 +19,18 @@ function init(projectDir, appName) { 'SampleApp': appName }; - var dest = f.replace(new RegExp('SampleApp', 'g'), appName); + var dest = f.replace(/SampleApp/g, appName).replace(/^_/, "."); copyAndReplace( path.resolve(source, f), path.resolve(projectDir, dest), replacements ); }); + + console.log('Next Steps:'); + console.log(' Open ' + path.resolve(projectDir, appName) + '.xcodeproj in Xcode'); + console.log(' Hit Run button'); + console.log(''); } function copyAndReplace(src, dest, replacements) { @@ -43,22 +48,6 @@ function copyAndReplace(src, dest, replacements) { } } -function copyAndReplace2(src, dest, appName) { - if (fs.lstatSync(src).isDirectory()) { - if (!fs.existsSync(dest)) { - fs.mkdirSync(dest); - } - } - else { - var content = fs.readFileSync(src, 'utf8') - .replace(new RegExp('SampleApp', 'g'), appName) - .replace(new RegExp('Examples/' + appName + '/', 'g'), '') - .replace(new RegExp('../../Libraries/', 'g'), 'node_modules/react-native/Libraries/') - .replace(new RegExp('../../React/', 'g'), 'node_modules/react-native/React/'); - fs.writeFileSync(dest, content); - } -} - function walk(current) { if(fs.lstatSync(current).isDirectory()) { var files = fs.readdirSync(current).map(function(child) { diff --git a/local-cli/cli.js b/local-cli/cli.js index 004074b32e2407..9db680309b1438 100644 --- a/local-cli/cli.js +++ b/local-cli/cli.js @@ -6,6 +6,8 @@ var spawn = require('child_process').spawn; var path = require('path'); + +var init = require('../init.js'); var install = require('./install.js'); var bundle = require('./bundle.js'); @@ -59,10 +61,6 @@ function run() { // Here goes any cli commands we need to } -function init(root, projectName) { - spawn(path.resolve(__dirname, '../init.sh'), [projectName], {stdio:'inherit'}); -} - if (require.main === module) { run(); }