Skip to content

Commit 26633bc

Browse files
Do not use spinner in CI environment
In case terminal is not interactive, the spinner we are using during `tns doctor` or `tns platform add ...` is printing a lot of messages and polutes the output. So in case we are in non-interactive environment, print the spinner message a single time. In order to achieve this, use the newly introduce method in $progressIndicatior from submodule; Add getSpinner method to $progressIndicator Add `getSpinner` method to $progressIndicator - it will return a new instance of clui.Spinner in case terminal is interactive. In case it is not - a mocked instance will be returned. This way in CI builds the spinner will not print tons of repeated messages.
1 parent f0d4908 commit 26633bc

7 files changed

+32
-5
lines changed

lib/services/doctor-service.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { EOL } from "os";
22
import * as semver from "semver";
33
import * as path from "path";
44
import * as helpers from "../common/helpers";
5-
const clui = require("clui");
65

76
class DoctorService implements IDoctorService {
87
private static PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__";
@@ -166,7 +165,7 @@ class DoctorService implements IDoctorService {
166165
};
167166
this.$fs.writeJson(path.join(projDir, "package.json"), packageJsonData);
168167

169-
const spinner = new clui.Spinner("Installing iOS runtime.");
168+
const spinner = this.$progressIndicator.getSpinner("Installing iOS runtime.");
170169
try {
171170
spinner.start();
172171
await this.$npm.install("tns-ios", projDir, {

lib/services/platform-service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { AppFilesUpdater } from "./app-files-updater";
99
import { attachAwaitDetach } from "../common/helpers";
1010
import * as temp from "temp";
1111
temp.track();
12-
const clui = require("clui");
1312

1413
const buildInfoFileName = ".nsbuildinfo";
1514

@@ -25,6 +24,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
2524
constructor(private $devicesService: Mobile.IDevicesService,
2625
private $preparePlatformNativeService: IPreparePlatformService,
2726
private $preparePlatformJSService: IPreparePlatformService,
27+
private $progressIndicator: IProgressIndicator,
2828
private $errors: IErrors,
2929
private $fs: IFileSystem,
3030
private $logger: ILogger,
@@ -115,7 +115,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
115115
npmOptions["version"] = version;
116116
}
117117

118-
const spinner = new clui.Spinner("Installing " + packageToInstall);
118+
const spinner = this.$progressIndicator.getSpinner("Installing " + packageToInstall);
119119
const projectDir = projectData.projectDir;
120120
const platformPath = path.join(projectData.platformsDir, platform);
121121

test/npm-support.ts

+7
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ function createTestInjector(): IInjector {
8989
testInjector.register("nodeModulesDependenciesBuilder", NodeModulesDependenciesBuilder);
9090
testInjector.register("settingsService", SettingsService);
9191
testInjector.register("devicePathProvider", {});
92+
testInjector.register("progressIndicator", {
93+
getSpinner: (msg: string) => ({
94+
start: (): void => undefined,
95+
stop: (): void => undefined,
96+
message: (): void => undefined
97+
})
98+
});
9299

93100
return testInjector;
94101
}

test/platform-commands.ts

+7
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ function createTestInjector() {
153153
showCommandLineHelp: async (): Promise<void> => (undefined)
154154
});
155155
testInjector.register("settingsService", SettingsService);
156+
testInjector.register("progressIndicator", {
157+
getSpinner: (msg: string) => ({
158+
start: (): void => undefined,
159+
stop: (): void => undefined,
160+
message: (): void => undefined
161+
})
162+
});
156163

157164
return testInjector;
158165
}

test/platform-service.ts

+7
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ function createTestInjector() {
9696
showCommandLineHelp: async (): Promise<void> => (undefined)
9797
});
9898
testInjector.register("settingsService", SettingsService);
99+
testInjector.register("progressIndicator", {
100+
getSpinner: (msg: string) => ({
101+
start: (): void => undefined,
102+
stop: (): void => undefined,
103+
message: (): void => undefined
104+
})
105+
});
99106

100107
return testInjector;
101108
}

test/plugins-service.ts

+7
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ function createTestInjector() {
103103
showCommandLineHelp: async (): Promise<void> => (undefined)
104104
});
105105
testInjector.register("settingsService", SettingsService);
106+
testInjector.register("progressIndicator", {
107+
getSpinner: (msg: string) => ({
108+
start: (): void => undefined,
109+
stop: (): void => undefined,
110+
message: (): void => undefined
111+
})
112+
});
106113

107114
return testInjector;
108115
}

0 commit comments

Comments
 (0)