Skip to content

More tslint changes #818

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 1 commit into from
Aug 26, 2015
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
2 changes: 1 addition & 1 deletion lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $injector.requireCommand("platform|add", "./commands/add-platform");
$injector.requireCommand("platform|remove", "./commands/remove-platform");
$injector.requireCommand("platform|update", "./commands/update-platform");
$injector.requireCommand("library|add", "./commands/add-library");
$injector.requireCommand("run|ios", "./commands/run");
$injector.requireCommand("run|ios", "./commands/run");
$injector.requireCommand("run|android", "./commands/run");

$injector.requireCommand("debug|ios", "./commands/debug");
Expand Down
14 changes: 8 additions & 6 deletions lib/commands/add-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,25 @@ export class AddLibraryCommand implements ICommand {
if (args.length !== 2) {
this.$errors.fail("This command needs two parameters.");
}
let platform = args[0];
let platformLowerCase = platform.toLowerCase();

let platform = args[0];
let platformLowerCase = platform.toLowerCase();
let libraryPath = path.resolve(args[1]);
if(platformLowerCase === "android") {
if(!this.$fs.exists(path.join(libraryPath, "project.properties")).wait()) {
let files = this.$fs.enumerateFilesInDirectorySync(libraryPath);
if(!_.any(files, file => path.extname(file) === ".jar")) {
this.$errors.failWithoutHelp("Invalid library path. Ensure that the library path is the file path to a directory containing one or more `*.jar` files or to a directory containing the `project.properties` files.");
this.$errors.failWithoutHelp("Invalid library path. Ensure that the library path is the file path to a directory " +
"containing one or more `*.jar` files or to a directory containing the `project.properties` files.");
}
}
} else if(platformLowerCase === "ios") {
if(path.extname(libraryPath) !== ".framework") {
this.$errors.failWithoutHelp("Invalid library path. Ensure that the library path is a Cocoa Touch Framework with all build architectures enabled.");
this.$errors.failWithoutHelp("Invalid library path. Ensure that the library path is a Cocoa Touch Framework with " +
"all build architectures enabled.");
}
}

this.$platformService.validatePlatformInstalled(args[0]);
return true;
}).future<boolean>()();
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

export class InitCommand implements ICommand {
constructor(private $initService: IInitService) { }

public allowedParameters: ICommandParameter[] = [];
public enableHooks = false;

public execute(args: string[]): IFuture<void> {
return this.$initService.initialize();
}
Expand Down
14 changes: 7 additions & 7 deletions lib/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ export class InstallCommand implements ICommand {
private $projectDataService: IProjectDataService,
private $pluginsService: IPluginsService,
private $logger: ILogger) { }

public enableHooks = false;

public allowedParameters: ICommandParameter[] = [];

public execute(args: string[]): IFuture<void> {
return (() => {
let error: string = "";

this.$pluginsService.ensureAllDependenciesAreInstalled().wait();

this.$projectDataService.initialize(this.$projectData.projectDir);
_.each(this.$platformsData.platformsNames, platform => {
let platformData = this.$platformsData.getPlatformData(platform);
Expand All @@ -31,11 +31,11 @@ export class InstallCommand implements ICommand {
}
}
});

if(error) {
this.$logger.error(error);
}

}).future<void>()();
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/list-platforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export class ListPlatformsCommand implements ICommand {
}
this.$logger.out("Installed platforms: ", helpers.formatListOfNames(installedPlatforms, "and"));
} else {
this.$logger.out("Available platforms for this OS: ", helpers.formatListOfNames(this.$platformService.getAvailablePlatforms().wait(), "and"));
let formattedPlatformsList = helpers.formatListOfNames(this.$platformService.getAvailablePlatforms().wait(), "and");
this.$logger.out("Available platforms for this OS: ", formattedPlatformsList);
this.$logger.out("No installed platforms found. Use $ tns platform add");
}
}).future<void>()();
Expand Down
10 changes: 5 additions & 5 deletions lib/commands/livesync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ export class LivesyncCommand implements ICommand {
private $errors: IErrors) { }

public execute(args: string[]): IFuture<void> {
this.$options.justlaunch = true;
this.$options.justlaunch = true;
return this.$usbLiveSyncService.liveSync(args[0]);
}

public canExecute(args: string[]): IFuture<boolean> {
return (() => {
if(args.length >= 2) {
this.$errors.fail("Invalid number of arguments.");
}

let platform = args[0];
if(platform) {
return _.contains(this.$mobileHelper.platformNames, this.$mobileHelper.normalizePlatformName(platform));
}

return true;
}).future<boolean>()();
}

allowedParameters: ICommandParameter[] = [];
}
$injector.registerCommand("livesync", LivesyncCommand);
12 changes: 6 additions & 6 deletions lib/commands/plugin/add-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
export class AddPluginCommand implements ICommand {
constructor(private $pluginsService: IPluginsService,
private $errors: IErrors) { }

execute(args: string[]): IFuture<void> {
return this.$pluginsService.add(args[0]);
}

canExecute(args: string[]): IFuture<boolean> {
return (() => {
if(!args[0]) {
this.$errors.fail("You must specify plugin name.");
}

let installedPlugins = this.$pluginsService.getAllInstalledPlugins().wait();
let pluginName = args[0].toLowerCase();
if(_.any(installedPlugins, (plugin: IPluginData) => plugin.name.toLowerCase() === pluginName)) {
this.$errors.failWithoutHelp(`Plugin "${pluginName}" is already installed.`);
}
return true;

return true;
}).future<boolean>()();
}

public allowedParameters: ICommandParameter[] = [];
}
$injector.registerCommand("plugin|add", AddPluginCommand);
10 changes: 5 additions & 5 deletions lib/commands/plugin/remove-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
export class RemovePluginCommand implements ICommand {
constructor(private $pluginsService: IPluginsService,
private $errors: IErrors) { }

execute(args: string[]): IFuture<void> {
return this.$pluginsService.remove(args[0]);
}

canExecute(args: string[]): IFuture<boolean> {
return (() => {
if(!args[0]) {
this.$errors.fail("You must specify plugin name.");
}

let installedPlugins = this.$pluginsService.getAllInstalledPlugins().wait();
let pluginName = args[0].toLowerCase();
if(!_.any(installedPlugins, (plugin: IPluginData) => plugin.name.toLowerCase() === pluginName)) {
this.$errors.failWithoutHelp(`Plugin "${pluginName}" is not installed.`);
}

return true;
}).future<boolean>()();
}

public allowedParameters: ICommandParameter[] = [];
}
$injector.registerCommand("plugin|remove", RemovePluginCommand);
2 changes: 1 addition & 1 deletion lib/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class RunAndroidCommand extends RunCommandBase implements ICommand {
private $platformsData: IPlatformsData) {
super($platformService);
}

public allowedParameters: ICommandParameter[] = [];

public execute(args: string[]): IFuture<void> {
Expand Down
8 changes: 4 additions & 4 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export class StaticConfig extends staticConfigBaseLibPath.StaticConfigBase imple
public ERROR_REPORT_SETTING_NAME = "TrackExceptions";
public ANALYTICS_INSTALLATION_ID_SETTING_NAME = "AnalyticsInstallationID";
public START_PACKAGE_ACTIVITY_NAME = "com.tns.NativeScriptActivity";

constructor($injector: IInjector) {
super($injector);
super($injector);
}

public get SYS_REQUIREMENTS_LINK(): string {
let linkToSysRequirements: string;
switch(process.platform) {
Expand Down Expand Up @@ -63,7 +63,7 @@ export class StaticConfig extends staticConfigBaseLibPath.StaticConfigBase imple
public get HTML_CLI_HELPERS_DIR(): string {
return path.join(__dirname, "../docs/helpers");
}

public get pathToPackageJson(): string {
return path.join(__dirname, "..", "package.json");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface INpmInstallOptions {
interface IDependencyData {
name: string;
version: string;
nativescript: any;
nativescript: any;
dependencies?: IStringDictionary;
devDependencies?: IStringDictionary;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/lockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import * as path from "path";

export class LockFile implements ILockFile {
private lockFilePath: string;

constructor(private $options: IOptions) {
this.lockFilePath = path.join(this.$options.profileDir, ".lock");
}

private static LOCK_EXPIRY_PERIOD_SEC = 180;
private static LOCK_PARAMS = {
retryWait: 100,
Expand Down
20 changes: 10 additions & 10 deletions lib/node-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"use strict";

import Future = require("fibers/future");
import npm = require("npm");
import * as npm from "npm";

export class NodePackageManager implements INodePackageManager {
constructor(private $childProcess: IChildProcess,
Expand All @@ -15,7 +15,7 @@ export class NodePackageManager implements INodePackageManager {
public getCache(): string {
return npm.cache;
}

public load(config?: any): IFuture<void> {
let future = new Future<void>();
npm.load(config, (err) => {
Expand All @@ -27,7 +27,7 @@ export class NodePackageManager implements INodePackageManager {
});
return future;
}

public install(packageName: string, pathToSave: string, config?: any): IFuture<any> {
if(this.$options.ignoreScripts) {
config = config || {};
Expand All @@ -36,7 +36,7 @@ export class NodePackageManager implements INodePackageManager {

return this.loadAndExecute("install", [pathToSave, packageName], { config: config });
}

public uninstall(packageName: string, config?: any): IFuture<any> {
return this.loadAndExecute("uninstall", [[packageName]], { config: config });
}
Expand All @@ -45,28 +45,28 @@ export class NodePackageManager implements INodePackageManager {
// function cache (pkg, ver, where, scrub, cb)
return this.loadAndExecute("cache", [packageName, version, undefined, false], { subCommandName: "add", config: config });
}

public cacheUnpack(packageName: string, version: string, unpackTarget?: string): IFuture<void> {
// function unpack (pkg, ver, unpackTarget, dMode, fMode, uid, gid, cb)
return this.loadAndExecute("cache", [packageName, version, unpackTarget, null, null, null, null], { subCommandName: "unpack" });
}

public view(packageName: string, propertyName: string): IFuture<any> {
return this.loadAndExecute("view", [[packageName, propertyName], [false]]);
}

public executeNpmCommand(npmCommandName: string, currentWorkingDirectory: string): IFuture<any> {
return this.$childProcess.exec(npmCommandName, { cwd: currentWorkingDirectory });
}

private loadAndExecute(commandName: string, args: any[], opts?: { config?: any, subCommandName?: string }): IFuture<any> {
return (() => {
opts = opts || {};
this.load(opts.config).wait();
return this.executeCore(commandName, args, opts.subCommandName).wait();
}).future<any>()();
}

private executeCore(commandName: string, args: any[], subCommandName?: string): IFuture<any> {
let future = new Future<any>();
let callback = (err: Error, data: any) => {
Expand All @@ -77,10 +77,10 @@ export class NodePackageManager implements INodePackageManager {
}
};
args.push(callback);

let command = subCommandName ? npm.commands[commandName][subCommandName] : npm.commands[commandName];
command.apply(this, args);

return future;
}
}
Expand Down
Loading