Skip to content

Commit

Permalink
Linked with new local-cli, refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeStanton committed May 14, 2015
1 parent 2e2e577 commit 52e7b80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
23 changes: 6 additions & 17 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions local-cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 52e7b80

Please sign in to comment.