Skip to content

Commit 6d690fe

Browse files
committed
Revert "Workaround for NativeScript/nativescript-cli#2292"
This reverts commit c432780.
1 parent c432780 commit 6d690fe

File tree

2 files changed

+30
-58
lines changed

2 files changed

+30
-58
lines changed

src/debug-adapter/webKitDebugAdapter.ts

+30-45
Original file line numberDiff line numberDiff line change
@@ -141,56 +141,41 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
141141
this._request = new DebugRequest(args, Services.cli());
142142
Services.extensionClient().analyticsLaunchDebugger({ request: this._request.isSync ? "sync" : args.request, platform: args.platform });
143143

144-
// FIXME: Workaround for https://github.com/NativeScript/nativescript-cli/issues/2292
145-
let cliBuildCommand = Promise.resolve();
146-
if (this._request.isSync && !fs.existsSync(this._request.project.platformBuildPath())) {
147-
cliBuildCommand = new Promise((resolve, reject) => {
148-
let cliBuildProcess = this._request.project.build([]);
149-
cliBuildProcess.stdout.on('data', data => { Services.logger().log(data.toString(), Tags.FrontendMessage); });
150-
cliBuildProcess.stderr.on('data', data => { Services.logger().error(data.toString(), Tags.FrontendMessage); });
151-
cliBuildProcess.on('close', (code) => {
152-
code ? reject(`The build command exited with code: ${code}`) : resolve();
153-
});
154-
});
144+
// Run CLI Command
145+
let cliCommand: DebugResult;
146+
if (this._request.isLaunch) {
147+
cliCommand = this._request.project.debug({ stopOnEntry: this._request.launchArgs.stopOnEntry }, this._request.args.tnsArgs);
148+
}
149+
else if (this._request.isSync) {
150+
cliCommand = this._request.project.debugWithSync({ stopOnEntry: this._request.launchArgs.stopOnEntry, syncAllFiles: this._request.launchArgs.syncAllFiles }, this._request.args.tnsArgs);
151+
}
152+
else if (this._request.isAttach) {
153+
cliCommand = this._request.project.attach(this._request.args.tnsArgs);
155154
}
156155

157-
return cliBuildCommand.then(() => {
158-
// Run CLI Command
159-
let cliCommand: DebugResult;
160-
if (this._request.isLaunch) {
161-
cliCommand = this._request.project.debug({ stopOnEntry: this._request.launchArgs.stopOnEntry }, this._request.args.tnsArgs);
162-
}
163-
else if (this._request.isSync) {
164-
cliCommand = this._request.project.debugWithSync({ stopOnEntry: this._request.launchArgs.stopOnEntry, syncAllFiles: this._request.launchArgs.syncAllFiles }, this._request.args.tnsArgs);
165-
}
166-
else if (this._request.isAttach) {
167-
cliCommand = this._request.project.attach(this._request.args.tnsArgs);
168-
}
169-
170-
if (cliCommand.tnsProcess) {
171-
cliCommand.tnsProcess.stdout.on('data', data => { Services.logger().log(data.toString(), Tags.FrontendMessage); });
172-
cliCommand.tnsProcess.stderr.on('data', data => { Services.logger().error(data.toString(), Tags.FrontendMessage); });
173-
cliCommand.tnsProcess.on('close', (code, signal) => { Services.logger().error(`The tns command finished its execution with code ${code}.`, Tags.FrontendMessage); });
174-
}
156+
if (cliCommand.tnsProcess) {
157+
cliCommand.tnsProcess.stdout.on('data', data => { Services.logger().log(data.toString(), Tags.FrontendMessage); });
158+
cliCommand.tnsProcess.stderr.on('data', data => { Services.logger().error(data.toString(), Tags.FrontendMessage); });
159+
cliCommand.tnsProcess.on('close', (code, signal) => { Services.logger().error(`The tns command finished its execution with code ${code}.`, Tags.FrontendMessage); });
160+
}
175161

176-
let promiseResolve = null;
177-
let promise: Promise<void> = new Promise<void>((res, rej) => { promiseResolve = res; });
178-
// Attach to the running application
179-
cliCommand.tnsOutputEventEmitter.on('readyForConnection', (connectionToken: string | number) => {
180-
connectionToken = this._request.isAndroid ? this._request.androidProject.getDebugPortSync() : connectionToken;
181-
Services.logger().log(`Attaching to application on ${connectionToken}`);
182-
let connection: INSDebugConnection = this._request.isAndroid ? new AndroidConnection() : new IosConnection();
183-
this.setConnection(connection);
184-
let attachPromise = this._request.isAndroid ? (<AndroidConnection>connection).attach(<number>connectionToken, 'localhost') : (<IosConnection>connection).attach(<string>connectionToken);
185-
attachPromise.then(() => {
186-
// Send InitializedEvent
187-
this.fireEvent(new InitializedEvent());
188-
promiseResolve();
189-
});
162+
let promiseResolve = null;
163+
let promise: Promise<void> = new Promise<void>((res, rej) => { promiseResolve = res; });
164+
// Attach to the running application
165+
cliCommand.tnsOutputEventEmitter.on('readyForConnection', (connectionToken: string | number) => {
166+
connectionToken = this._request.isAndroid ? this._request.androidProject.getDebugPortSync() : connectionToken;
167+
Services.logger().log(`Attaching to application on ${connectionToken}`);
168+
let connection: INSDebugConnection = this._request.isAndroid ? new AndroidConnection() : new IosConnection();
169+
this.setConnection(connection);
170+
let attachPromise = this._request.isAndroid ? (<AndroidConnection>connection).attach(<number>connectionToken, 'localhost') : (<IosConnection>connection).attach(<string>connectionToken);
171+
attachPromise.then(() => {
172+
// Send InitializedEvent
173+
this.fireEvent(new InitializedEvent());
174+
promiseResolve();
190175
});
191-
192-
return promise;
193176
});
177+
178+
return promise;
194179
});
195180

196181
}

src/project/project.ts

-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {ChildProcess} from 'child_process';
22
import {EventEmitter} from 'events';
3-
import * as path from 'path';
43
import {Version} from '../common/version';
54
import {NativeScriptCli} from './nativeScriptCli';
65

@@ -21,14 +20,6 @@ export abstract class Project {
2120

2221
public abstract platformName(): string;
2322

24-
public platformBuildPath(): string {
25-
return path.join(this.appRoot, 'platforms', this.platformName(), 'build');
26-
}
27-
28-
public build(tnsArgs: string[]): ChildProcess {
29-
return this.executeBuildCommand(tnsArgs);
30-
}
31-
3223
public run(tnsArgs?: string[]): ChildProcess {
3324
return this.executeRunCommand(tnsArgs);
3425
}
@@ -43,10 +34,6 @@ export abstract class Project {
4334
return this.cli.execute(["run", this.platformName()].concat(args), this._appRoot);
4435
}
4536

46-
protected executeBuildCommand(args: string[]): ChildProcess {
47-
return this.cli.execute(["build", this.platformName()].concat(args), this._appRoot);
48-
}
49-
5037
protected executeDebugCommand(args: string[]): ChildProcess {
5138
return this.cli.execute(["debug", this.platformName(), "--no-client"].concat(args), this._appRoot);
5239
}

0 commit comments

Comments
 (0)