diff --git a/local-cli/__tests__/install-test.js b/local-cli/__tests__/install-test.js
new file mode 100644
index 000000000..b3d374522
--- /dev/null
+++ b/local-cli/__tests__/install-test.js
@@ -0,0 +1,44 @@
+'use strict';
+
+jest.dontMock('../install');
+jest.dontMock('fs');
+jest.dontMock('path');
+
+var install = require('../install.js');
+
+var openingReactTag = '#';
+var closingReactTag = '#';
+
+var fs = require.requireActual('fs');
+var path = require.requireActual('path');
+
+process.chdir(__dirname);
+
+describe('setup Podfile', function() {
+
+ it('creates a Podfile if none exists', function() {
+ try {
+ fs.unlinkSync(path.resolve(__dirname, 'Podfile'));
+ } catch(e) {}
+
+ var setupPodfile = install.setupPodfile();
+
+ expect(setupPodfile.created).toBe(true);
+ });
+
+ it('does not create Podfile if one exists', function() {
+ var setupPodfile = install.setupPodfile();
+ expect(setupPodfile.created).toBe(false);
+ });
+
+ it('includes React Native Tags', function() {
+ var setupPodfile = install.setupPodfile();
+
+ expect(setupPodfile.podfileText).toContain(openingReactTag);
+ expect(setupPodfile.podfileText).toContain(closingReactTag);
+
+ try {
+ fs.unlinkSync(path.resolve(__dirname, 'Podfile'));
+ } catch(e) {}
+ });
+});
diff --git a/local-cli/__tests__/setupPodfileTests.js b/local-cli/__tests__/setupPodfileTests.js
deleted file mode 100644
index c970e769c..000000000
--- a/local-cli/__tests__/setupPodfileTests.js
+++ /dev/null
@@ -1,38 +0,0 @@
-'use strict';
-
-jest.dontMock('../install');
-
-var install = require('../install.js');
-var fs = require('fs');
-
-describe('setup Podfile', function() {
- it('creates a Podfile', function() {
- fs.mkdirSync('./podfile-test');
- process.chdir('./podfile-test');
- var setupPodfile = install.setupPodfile();
-
- expect(setupPodfile.podfileExists()).toBe(true);
- process.chdir('../');
- });
-
- it('expects Podfile to containing opening & closing react native tag', function() {
- process.chdir('./podfile-test');
- var setupPodfile = install.setupPodfile();
-
- var openingReactTag = '#';
- var closingReactTag = '#';
-
- expect(setupPodfile.podfileText()).toContain(openingReactTag);
- expect(setupPodfile.podfileText()).toContain(closingReactTag);
- process.chdir('../');
- });
-
- it('expects Podfile to contain React Pod', function() {
- process.chdir('./podfile-test');
- var setupPodfile = install.setupPodfile();
- expect(setupPodfile.podfileText()).toContain('pod \'React\'');
- process.chdir('../');
- fs.unlink("./podfile-test/Podfile");
- fs.rmdirSync("./podfile-test");
- });
-});
diff --git a/local-cli/install.js b/local-cli/install.js
index e0158620f..63e763667 100644
--- a/local-cli/install.js
+++ b/local-cli/install.js
@@ -5,11 +5,12 @@
'use strict';
var fs = require('fs');
+var path = require('path');
var exec = require('child_process').exec;
-var NODE_MODULE_PATH = './node_modules';
+var NODE_MODULE_PATH = path.resolve(__dirname, 'node_modules');
-var PODFILE_PATH = './Podfile';
+var PODFILE_PATH = path.resolve(__dirname, 'Podfile');
function addDependency(name, path) {
console.log('Found dependency: ' + name);
@@ -48,6 +49,10 @@ function installDependecies() {
module.exports = {
setupPodfile: function() {
+ var returnArgs = {
+ created: false
+ };
+
var podfileText;
try {
podfileText = fs.readFileSync(PODFILE_PATH, 'utf8');
@@ -58,6 +63,7 @@ module.exports = {
var reactPodfileBoilerplate = openingReactTag + closingReactTag;
if (!podfileText) {
+ returnArgs.created = true;
fs.appendFileSync(PODFILE_PATH, reactPodfileBoilerplate);
} else {
if (podfileText.indexOf(openingReactTag) === -1 || podfileText.indexOf(closingReactTag) === -1) {
@@ -67,6 +73,7 @@ module.exports = {
try {
podfileText = fs.readFileSync(PODFILE_PATH, 'utf8');
+ returnArgs.podfileText = podfileText;
} catch(e) {}
if (podfileText.indexOf('pod \'React\'') === -1) {
@@ -79,24 +86,13 @@ module.exports = {
podfileText.slice(indexOfReactComponents)].join('');
fs.writeFileSync(PODFILE_PATH, newPodfileText);
+ returnArgs.podfileText = newPodfileText;
} catch(e) {
throw e;
}
}
- return {
- podfileExists: function() {
- try {
- var podfileText = fs.readFileSync(PODFILE_PATH, 'utf8');
- return true;
- } catch(e) {
- return false;
- }
- },
- podfileText: function() {
- return podfileText;
- }
- };
+ return returnArgs;
},
init: function(arguement) {
// arguement is available for future arguement commands