Skip to content

Commit 822969b

Browse files
Make fs.readText, IEmulatorPlatformServices.checkAvailability, IAutoCompletionService.isAutoCompletionEnabled and IAutoCompletionService.isObsoleteAutoCompletionEnabled sync
1 parent 13df2a0 commit 822969b

14 files changed

+43
-44
lines changed

lib/commands/test-init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class TestInitCommand implements ICommand {
4848

4949
this.$fs.ensureDirectoryExists(testsDir);
5050

51-
let karmaConfTemplate = this.$resources.readText('test/karma.conf.js').wait();
51+
let karmaConfTemplate = this.$resources.readText('test/karma.conf.js');
5252
let karmaConf = _.template(karmaConfTemplate)({
5353
frameworks: [frameworkToInstall].concat(dependencies)
5454
.map(fw => `'${fw}'`)

lib/services/android-project-service.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
268268
this.$androidToolsInfo.validateInfo({ showWarningsAsErrors: true, validateTargetSdk: true }).wait();
269269
let androidToolsInfo = this.$androidToolsInfo.getToolsInfo().wait();
270270
let compileSdk = androidToolsInfo.compileSdkVersion;
271-
let targetSdk = this.getTargetFromAndroidManifest().wait() || compileSdk;
271+
let targetSdk = this.getTargetFromAndroidManifest() || compileSdk;
272272
let buildToolsVersion = androidToolsInfo.buildToolsVersion;
273273
let appCompatVersion = androidToolsInfo.supportRepositoryVersion;
274274
let generateTypings = androidToolsInfo.generateTypings;
@@ -486,21 +486,19 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
486486
}
487487
}
488488

489-
private getTargetFromAndroidManifest(): IFuture<string> {
490-
return ((): string => {
491-
let versionInManifest: string;
492-
if (this.$fs.exists(this.platformData.configurationFilePath)) {
493-
let targetFromAndroidManifest: string = this.$fs.readText(this.platformData.configurationFilePath).wait();
494-
if (targetFromAndroidManifest) {
495-
let match = targetFromAndroidManifest.match(/.*?android:targetSdkVersion=\"(.*?)\"/);
496-
if (match && match[1]) {
497-
versionInManifest = match[1];
498-
}
489+
private getTargetFromAndroidManifest(): string {
490+
let versionInManifest: string;
491+
if (this.$fs.exists(this.platformData.configurationFilePath)) {
492+
let targetFromAndroidManifest: string = this.$fs.readText(this.platformData.configurationFilePath);
493+
if (targetFromAndroidManifest) {
494+
let match = targetFromAndroidManifest.match(/.*?android:targetSdkVersion=\"(.*?)\"/);
495+
if (match && match[1]) {
496+
versionInManifest = match[1];
499497
}
500498
}
499+
}
501500

502-
return versionInManifest;
503-
}).future<string>()();
501+
return versionInManifest;
504502
}
505503
}
506504
$injector.register("androidProjectService", AndroidProjectService);

lib/services/cocoapods-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class CocoaPodsService implements ICocoaPodsService {
2222
throw new Error(`The Podfile ${pathToPodfile} does not exist.`);
2323
}
2424

25-
let podfileContent = this.$fs.readText(pathToPodfile).wait();
25+
let podfileContent = this.$fs.readText(pathToPodfile);
2626
let hookStart = `${hookName} do`;
2727

2828
let hookDefinitionRegExp = new RegExp(`${hookStart} *(\\|(\\w+)\\|)?`, "g");

lib/services/ios-project-service.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
435435
let platformData = this.platformData;
436436
let projectPath = path.join(platformData.projectRoot, this.$projectData.projectName);
437437
let projectPlist = this.getInfoPlistPath();
438-
let plistContent = plist.parse(this.$fs.readText(projectPlist).wait());
438+
let plistContent = plist.parse(this.$fs.readText(projectPlist));
439439
let storyName = plistContent["UILaunchStoryboardName"];
440440
this.$logger.trace(`Examining ${projectPlist} UILaunchStoryboardName: "${storyName}".`);
441441
if (storyName !== "LaunchScreen") {
@@ -590,7 +590,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
590590
this.$logger.trace("Schedule merge plist at: " + plistPath);
591591
session.patch({
592592
name: path.relative(projectDir, plistPath),
593-
read: () => this.$fs.readText(plistPath).wait()
593+
read: () => this.$fs.readText(plistPath)
594594
});
595595
};
596596

@@ -696,7 +696,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
696696
public afterPrepareAllPlugins(): IFuture<void> {
697697
return (() => {
698698
if (this.$fs.exists(this.projectPodFilePath)) {
699-
let projectPodfileContent = this.$fs.readText(this.projectPodFilePath).wait();
699+
let projectPodfileContent = this.$fs.readText(this.projectPodFilePath);
700700
this.$logger.trace("Project Podfile content");
701701
this.$logger.trace(projectPodfileContent);
702702

@@ -772,7 +772,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
772772

773773
private replaceFileContent(file: string): IFuture<void> {
774774
return (() => {
775-
let fileContent = this.$fs.readText(file).wait();
775+
let fileContent = this.$fs.readText(file);
776776
let replacedContent = helpers.stringReplaceAll(fileContent, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, this.$projectData.projectName);
777777
this.$fs.writeFile(file, replacedContent).wait();
778778
}).future<void>()();
@@ -840,9 +840,9 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
840840
return (() => {
841841
let pluginPodFilePath = path.join(pluginPlatformsFolderPath, "Podfile");
842842
if (this.$fs.exists(pluginPodFilePath)) {
843-
let pluginPodFileContent = this.$fs.readText(pluginPodFilePath).wait(),
843+
let pluginPodFileContent = this.$fs.readText(pluginPodFilePath),
844844
pluginPodFilePreparedContent = this.buildPodfileContent(pluginPodFilePath, pluginPodFileContent),
845-
projectPodFileContent = this.$fs.exists(this.projectPodFilePath) ? this.$fs.readText(this.projectPodFilePath).wait() : "";
845+
projectPodFileContent = this.$fs.exists(this.projectPodFilePath) ? this.$fs.readText(this.projectPodFilePath) : "";
846846

847847
if (!~projectPodFileContent.indexOf(pluginPodFilePreparedContent)) {
848848
let podFileHeader = this.$cocoapodsService.getPodfileHeader(this.$projectData.projectName),
@@ -904,8 +904,8 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
904904
return (() => {
905905
let pluginPodFilePath = path.join(pluginPlatformsFolderPath, "Podfile");
906906
if (this.$fs.exists(pluginPodFilePath) && this.$fs.exists(this.projectPodFilePath)) {
907-
let pluginPodFileContent = this.$fs.readText(pluginPodFilePath).wait();
908-
let projectPodFileContent = this.$fs.readText(this.projectPodFilePath).wait();
907+
let pluginPodFileContent = this.$fs.readText(pluginPodFilePath);
908+
let projectPodFileContent = this.$fs.readText(this.projectPodFilePath);
909909
let contentToRemove = this.buildPodfileContent(pluginPodFilePath, pluginPodFileContent);
910910
projectPodFileContent = helpers.stringReplaceAll(projectPodFileContent, contentToRemove, "");
911911
if (projectPodFileContent.trim() === `use_frameworks!${os.EOL}${os.EOL}target "${this.$projectData.projectName}" do${os.EOL}${os.EOL}end`) {
@@ -1081,7 +1081,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
10811081
let teamIds: any = {};
10821082
for (let file of files) {
10831083
let filePath = path.join(dir, file);
1084-
let data = this.$fs.readText(filePath, "utf8").wait();
1084+
let data = this.$fs.readText(filePath, "utf8");
10851085
let teamId = this.getProvisioningProfileValue("TeamIdentifier", data);
10861086
let teamName = this.getProvisioningProfileValue("TeamName", data);
10871087
if (teamId) {

lib/services/livesync/ios-device-livesync-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ class IOSLiveSyncService implements IDeviceLiveSyncService {
116116
}).future<void>()();
117117
}
118118

119-
private liveEdit(localToDevicePaths: Mobile.ILocalToDevicePathData[]) {
119+
private liveEdit(localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> {
120120
return (() => {
121121
_.each(localToDevicePaths, localToDevicePath => {
122-
let content = this.$fs.readText(localToDevicePath.getLocalPath()).wait();
122+
let content = this.$fs.readText(localToDevicePath.getLocalPath());
123123
let message = JSON.stringify({
124124
method: "Debugger.setScriptSource",
125125
params: {

lib/services/platform-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export class PlatformService implements IPlatformService {
331331
let buildInfoFile = path.join(buildInfoFilePath, buildInfoFileName);
332332
if (!shouldBuild) {
333333
if (this.$fs.exists(buildInfoFile)) {
334-
let buildInfoText = this.$fs.readText(buildInfoFile).wait();
334+
let buildInfoText = this.$fs.readText(buildInfoFile);
335335
shouldBuild = this._prepareInfo.time !== buildInfoText;
336336
} else {
337337
shouldBuild = true;

lib/services/plugin-variables-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class PluginVariablesService implements IPluginVariablesService {
3838

3939
public interpolatePluginVariables(pluginData: IPluginData, pluginConfigurationFilePath: string): IFuture<void> {
4040
return (() => {
41-
let pluginConfigurationFileContent = this.$fs.readText(pluginConfigurationFilePath).wait();
41+
let pluginConfigurationFileContent = this.$fs.readText(pluginConfigurationFilePath);
4242
this.executeForAllPluginVariables(pluginData, (pluginVariableData: IPluginVariableData) =>
4343
(() => {
4444
this.ensurePluginVariableValue(pluginVariableData.value, `Unable to find the value for ${pluginVariableData.name} plugin variable into project package.json file. Verify that your package.json file is correct and try again.`);
@@ -50,7 +50,7 @@ export class PluginVariablesService implements IPluginVariablesService {
5050

5151
public interpolateAppIdentifier(pluginConfigurationFilePath: string): IFuture<void> {
5252
return (() => {
53-
let pluginConfigurationFileContent = this.$fs.readText(pluginConfigurationFilePath).wait();
53+
let pluginConfigurationFileContent = this.$fs.readText(pluginConfigurationFilePath);
5454
let newContent = this.interpolateCore("nativescript.id", this.$projectData.projectId, pluginConfigurationFileContent);
5555
this.$fs.writeFile(pluginConfigurationFilePath, newContent).wait();
5656
}).future<void>()();

lib/services/project-data-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class ProjectDataService implements IProjectDataService {
6868
}
6969

7070
// Detect indent and use it later to write JSON.
71-
let projectFileContent = this.$fs.readText(this.projectFilePath).wait();
71+
let projectFileContent = this.$fs.readText(this.projectFilePath);
7272

7373
this.projectFileIndent = projectFileContent ? this.detectIndent(projectFileContent) : "\t";
7474

lib/xml-validator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ export class XmlValidator implements IXmlValidator {
2323
}).future<boolean>()();
2424
}
2525

26+
// TODO: Remove IFuture, reason: readText
2627
public getXmlFileErrors(sourceFile: string): IFuture<string> {
2728
return ((): string => {
2829
let errorOutput = "";
29-
let fileContents = this.$fs.readText(sourceFile).wait();
30+
let fileContents = this.$fs.readText(sourceFile);
3031
let domErrorHandler = (level:any, msg:string) => {
3132
errorOutput += level + EOL + msg + EOL;
3233
};

test/android-project-properties-manager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe("Android project properties parser tests", () => {
4242

4343
let expectedContent = 'target=android-21' + '\n' +
4444
'android.library.reference.1=testValue';
45-
let actualContent = fs.readText(path.join(tempFolder, "project.properties")).wait();
45+
let actualContent = fs.readText(path.join(tempFolder, "project.properties"));
4646

4747
assert.equal(expectedContent, actualContent);
4848
assert.equal(1, _.keys(projectPropertiesManager.getProjectReferences().wait()).length);
@@ -63,7 +63,7 @@ describe("Android project properties parser tests", () => {
6363
let expectedContent = ['target=android-21',
6464
'android.library.reference.1=someValue',
6565
'android.library.reference.2=testValue'].join('\n');
66-
let actualContent = fs.readText(path.join(tempFolder, "project.properties")).wait();
66+
let actualContent = fs.readText(path.join(tempFolder, "project.properties"));
6767

6868
assert.equal(expectedContent, actualContent);
6969
assert.equal(2, _.keys(projectPropertiesManager.getProjectReferences().wait()).length);
@@ -88,7 +88,7 @@ describe("Android project properties parser tests", () => {
8888
let expectedContent = projectPropertiesFileContent + '\n' +
8989
'android.library.reference.6=testValue';
9090

91-
let actualContent = fs.readText(path.join(tempFolder, "project.properties")).wait();
91+
let actualContent = fs.readText(path.join(tempFolder, "project.properties"));
9292

9393
assert.equal(expectedContent, actualContent);
9494
assert.equal(6, _.keys(projectPropertiesManager.getProjectReferences().wait()).length);
@@ -107,7 +107,7 @@ describe("Android project properties parser tests", () => {
107107
projectPropertiesManager.removeProjectReference("value1").wait();
108108

109109
let expectedContent = 'target=android-21';
110-
let actualContent = fs.readText(path.join(tempFolder, "project.properties")).wait();
110+
let actualContent = fs.readText(path.join(tempFolder, "project.properties"));
111111

112112
assert.equal(expectedContent, actualContent);
113113
assert.equal(0, _.keys(projectPropertiesManager.getProjectReferences().wait()).length);
@@ -134,7 +134,7 @@ describe("Android project properties parser tests", () => {
134134
'android.library.reference.2=value2',
135135
'android.library.reference.3=value4',
136136
'android.library.reference.4=value5'].join('\n') + '\n';
137-
let actualContent = fs.readText(path.join(tempFolder, "project.properties")).wait();
137+
let actualContent = fs.readText(path.join(tempFolder, "project.properties"));
138138

139139
assert.equal(expectedContent, actualContent);
140140
assert.equal(4, _.keys(projectPropertiesManager.getProjectReferences().wait()).length);

0 commit comments

Comments
 (0)