Skip to content

Fix debug android command #2713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/services/android-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,20 @@ class AndroidDebugService extends DebugServiceBase implements IPlatformDebugServ
private async waitForDebugger(packageName: String): Promise<void> {
let waitText: string = `0 /data/local/tmp/${packageName}-debugger-started`;
let maxWait = 12;
let debugerStarted: boolean = false;
while (maxWait > 0 && !debugerStarted) {
let debuggerStarted: boolean = false;
while (maxWait > 0 && !debuggerStarted) {
let forwardsResult = await this.device.adb.executeShellCommand(["ls", "-s", `/data/local/tmp/${packageName}-debugger-started`]);

maxWait--;

debugerStarted = forwardsResult.indexOf(waitText) === -1;
debuggerStarted = forwardsResult.indexOf(waitText) === -1;

if (!debugerStarted) {
sleep(500);
if (!debuggerStarted) {
await sleep(500);
}
}

if (debugerStarted) {
if (debuggerStarted) {
this.$logger.info("# NativeScript Debugger started #");
} else {
this.$logger.warn("# NativeScript Debugger did not start in time #");
Expand Down
108 changes: 0 additions & 108 deletions lib/tools/node-modules/node-modules-builder.ts
Original file line number Diff line number Diff line change
@@ -1,121 +1,13 @@
import * as constants from "../../../lib/constants";
import * as path from "path";
import * as shelljs from "shelljs";
import { TnsModulesCopy, NpmPluginPrepare } from "./node-modules-dest-copy";
import { NodeModulesDependenciesBuilder } from "./node-modules-dependencies-builder";
import { sleep, deferPromise } from "../../../lib/common/helpers";

let glob = require("glob");

export class NodeModulesBuilder implements INodeModulesBuilder {
constructor(private $fs: IFileSystem,
private $injector: IInjector,
private $lockfile: ILockFile,
private $options: IOptions
) { }

public async getChangedNodeModules(absoluteOutputPath: string, platform: string, projectData: IProjectData, lastModifiedTime?: Date): Promise<any> {
let projectDir = projectData.projectDir;
let isNodeModulesModified = false;
let nodeModulesPath = path.join(projectDir, constants.NODE_MODULES_FOLDER_NAME);
let nodeModules: any = {};

if (lastModifiedTime) {
let defer = deferPromise();

let match = new glob.Glob("node_modules/**", {
cwd: projectDir,
follow: true,
stat: true
}, (er: Error, files: string[]) => {
while (this.$lockfile.check()) {
sleep(10);
}

this.$lockfile.lock();
if (er) {
if (!defer.isResolved()) {
defer.reject(er);
}

this.$lockfile.unlock();
match.abort();
return;
}
for (let i = 0, l = files.length; i < l; i++) {
let file = files[i],
resolvedPath = path.join(projectDir, file),
relativePath = path.relative(projectDir, resolvedPath);
let stat = match.statCache[resolvedPath] || match.statCache[relativePath];
if (!stat) {
match.statCache[resolvedPath] = stat = this.$fs.getFsStats(resolvedPath);
}

if (stat.mtime <= lastModifiedTime) {
continue;
}
if (file === constants.NODE_MODULES_FOLDER_NAME) {
isNodeModulesModified = true;
this.$lockfile.unlock();
match.abort();
if (!defer.isResolved()) {
defer.resolve();
}

return;
}
let rootModuleName = path.normalize(file).split(path.sep)[1];
let rootModuleFullPath = path.join(nodeModulesPath, rootModuleName);
nodeModules[rootModuleFullPath] = rootModuleFullPath;
}

this.$lockfile.unlock();
});

match.on("end", () => {
if (!defer.isResolved()) {
let intervalId = setInterval(() => {
if (!this.$lockfile.check() || defer.isResolved()) {
if (!defer.isResolved()) {
defer.resolve();
}
clearInterval(intervalId);
}
}, 100);
}
});

await defer.promise;
}

if (isNodeModulesModified && this.$fs.exists(absoluteOutputPath)) {
let currentPreparedTnsModules = this.$fs.readDirectory(absoluteOutputPath);
let tnsModulesPath = path.join(projectDir, constants.NODE_MODULES_FOLDER_NAME, constants.TNS_CORE_MODULES_NAME);
let tnsModulesInApp = this.$fs.readDirectory(tnsModulesPath);
let modulesToDelete = _.difference(currentPreparedTnsModules, tnsModulesInApp);
_.each(modulesToDelete, moduleName => this.$fs.deleteDirectory(path.join(absoluteOutputPath, moduleName)));
}

if (!lastModifiedTime || isNodeModulesModified) {
this.expandScopedModules(nodeModulesPath, nodeModules);
}

return nodeModules;
}

private expandScopedModules(nodeModulesPath: string, nodeModules: IStringDictionary): void {
let nodeModulesDirectories = this.$fs.exists(nodeModulesPath) ? this.$fs.readDirectory(nodeModulesPath) : [];
_.each(nodeModulesDirectories, nodeModuleDirectoryName => {
let isNpmScope = /^@/.test(nodeModuleDirectoryName);
let nodeModuleFullPath = path.join(nodeModulesPath, nodeModuleDirectoryName);
if (isNpmScope) {
this.expandScopedModules(nodeModuleFullPath, nodeModules);
} else {
nodeModules[nodeModuleFullPath] = nodeModuleFullPath;
}
});
}

public async prepareNodeModules(absoluteOutputPath: string, platform: string, lastModifiedTime: Date, projectData: IProjectData): Promise<void> {
if (!this.$fs.exists(absoluteOutputPath)) {
// Force copying if the destination doesn't exist.
Expand Down