Skip to content

Commit 0056c37

Browse files
committed
Merge pull request #70 from NativeScript/fatme/fixes-and-improvements
Fixes and improvements
2 parents 21e0248 + 02cc9cb commit 0056c37

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

lib/node-package-manager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ export class NodePackageManager implements INodePackageManager {
6363
}
6464

6565
var incrementedVersion = semver.inc(currentVersion, constants.ReleaseType.MINOR);
66-
packageName = packageName + "@" + "<" + incrementedVersion;
66+
if(packageName.indexOf("@") < 0) {
67+
packageName = packageName + "@<" + incrementedVersion;
68+
}
6769
this.$logger.trace("Installing", packageName);
6870

6971
var future = new Future<void>();

lib/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var knownOpts:any = {
1111
"appid" : String,
1212
"copy-from": String,
1313
"link-to": String,
14-
"release": String,
14+
"release": Boolean,
1515
"device": Boolean,
1616
"emulator": Boolean,
1717
"version": Boolean,

lib/services/ios-project-service.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
///<reference path="../.d.ts"/>
22

3+
import Future = require("fibers/future");
34
import path = require("path");
45
import shell = require("shelljs");
56
import util = require("util");
@@ -86,9 +87,16 @@ class IOSProjectService implements IPlatformProjectService {
8687
return (() => {
8788
var appSourceDirectory = path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME);
8889
var appDestinationDirectory = path.join(platformData.projectRoot, this.$projectData.projectName);
90+
var resDirectory = path.join(platformData.projectRoot, this.$projectData.projectName, "Resources", "icons");
8991

9092
shell.cp("-r", path.join(appSourceDirectory, "*"), appDestinationDirectory);
9193

94+
var appResourcesDirectoryPath = path.join(appDestinationDirectory, constants.APP_RESOURCES_FOLDER_NAME);
95+
if (this.$fs.exists(appResourcesDirectoryPath).wait()) {
96+
shell.cp("-r", path.join(appResourcesDirectoryPath, platformData.normalizedPlatformName, "*"), resDirectory);
97+
this.$fs.deleteDirectory(appResourcesDirectoryPath).wait();
98+
}
99+
92100
return appDestinationDirectory;
93101
}).future<string>()();
94102
}
@@ -120,8 +128,7 @@ class IOSProjectService implements IPlatformProjectService {
120128
]);
121129
}
122130

123-
var childProcess = this.$childProcess.spawn("xcodebuild", args, {cwd: options, stdio: 'inherit'});
124-
this.$fs.futureFromEvent(childProcess, "exit").wait();
131+
this.spawn("xcodebuild", args, "exit", {cwd: options, stdio: 'inherit'}).wait();
125132

126133
if(options.device) {
127134
var buildOutputPath = path.join(projectRoot, "build", options.device ? "device" : "emulator");
@@ -134,12 +141,29 @@ class IOSProjectService implements IPlatformProjectService {
134141
"-o", path.join(buildOutputPath, this.$projectData.projectName + ".ipa")
135142
];
136143

137-
var childProcess = this.$childProcess.spawn("xcrun", xcrunArgs, {cwd: options, stdio: 'inherit'});
138-
this.$fs.futureFromEvent(childProcess, "exit").wait();
144+
this.spawn("xcrun", xcrunArgs, "exit", {cwd: options, stdio: 'inherit'}).wait();
139145
}
140146
}).future<void>()();
141147
}
142148

149+
private spawn(command: string, args: string[], event: string, options?: any): IFuture<void> { // event should be exit or close
150+
var future = new Future<void>();
151+
var childProcess = this.$childProcess.spawn(command, args, options);
152+
childProcess.once(event, () => {
153+
var args = _.toArray(arguments);
154+
var statusCode = args[0];
155+
var signal = args[1];
156+
157+
if(statusCode !== 0) {
158+
future.throw(util.format("Command %s exited with code %s", command, statusCode));
159+
} else {
160+
future.return();
161+
}
162+
});
163+
164+
return future;
165+
}
166+
143167
private replaceFileContent(file: string): IFuture<void> {
144168
return (() => {
145169
var fileContent = this.$fs.readText(file).wait();

lib/services/platform-service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class PlatformService implements IPlatformService {
104104

105105
// Need to remove unneeded node_modules folder
106106
// One level up is the runtime module and one above is the node_modules folder.
107-
this.$fs.deleteDirectory(path.join("../", frameworkDir)).wait();
107+
this.$fs.deleteDirectory(path.join(frameworkDir, "../../")).wait();
108108

109109
platformData.platformProjectService.interpolateData(platformData.projectRoot).wait();
110110
platformData.platformProjectService.afterCreateProject(platformData.projectRoot).wait();
@@ -141,8 +141,17 @@ export class PlatformService implements IPlatformService {
141141

142142
var appFilesLocation = platformProjectService.prepareProject(platformData).wait();
143143

144-
this.processPlatformSpecificFiles(platform, helpers.enumerateFilesInDirectorySync(path.join(appFilesLocation, constants.APP_FOLDER_NAME))).wait();
145-
this.processPlatformSpecificFiles(platform, helpers.enumerateFilesInDirectorySync(path.join(appFilesLocation, constants.TNS_MODULES_FOLDER_NAME))).wait();
144+
var appDirectoryPath = path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME);
145+
var contents = this.$fs.readDirectory(appDirectoryPath).wait();
146+
147+
_.each(contents, d => {
148+
var fsStat = this.$fs.getFsStats(path.join(appDirectoryPath, d)).wait();
149+
if(fsStat.isDirectory() && d !== constants.APP_RESOURCES_FOLDER_NAME) {
150+
this.processPlatformSpecificFiles(platform, helpers.enumerateFilesInDirectorySync(path.join(appFilesLocation, d))).wait();
151+
}
152+
});
153+
154+
this.$logger.out("Project successfully prepared");
146155

147156
}).future<void>()();
148157
}

0 commit comments

Comments
 (0)