@hkvstore/taco-cli
Version:
taco-cli is a command-line interface for rapid Apache Cordova development (forked from Microsoft taco-cli)
71 lines (69 loc) • 3.23 kB
JavaScript
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
/// <reference path="../../../typings/node.d.ts" />
/// <reference path="../../../typings/Q.d.ts" />
/// <reference path="../../../typings/rimraf.d.ts" />
/// <reference path="../../../typings/tacoUtils.d.ts" />
;
var fs = require("fs");
var path = require("path");
var Q = require("q");
var rimraf = require("rimraf");
var errorHelper = require("../tacoErrorHelper");
var PlatformHelper = require("./platformHelper");
var resources = require("../../resources/resourceManager");
var TacoErrorCodes = require("../tacoErrorCodes");
var tacoUtility = require("taco-utils");
var logger = tacoUtility.Logger;
var UtilHelper = tacoUtility.UtilHelper;
var CleanHelper = (function () {
function CleanHelper() {
}
CleanHelper.cleanPlatforms = function (platforms, commandData) {
return Q.all(platforms.map(function (platform) {
return CleanHelper.cleanPlatform(platform, commandData);
}));
};
CleanHelper.cleanPlatform = function (platform, commandData) {
switch (platform.location) {
case PlatformHelper.BuildLocationType.Local:
// To clean locally, try and run the clean script
var cleanScriptPath = path.join("platforms", platform.platform, "cordova", "clean");
if (fs.existsSync(cleanScriptPath)) {
return Q.denodeify(UtilHelper.loggedExec)(cleanScriptPath).fail(function (err) {
// If we can't run the script, then show a warning but continue
logger.logWarning(err.toString());
});
}
break;
case PlatformHelper.BuildLocationType.Remote:
var releaseString = "release";
var debugString = "debug";
var configurations = [];
if (commandData.options[releaseString]) {
configurations.push(releaseString);
}
if (commandData.options[debugString]) {
configurations.push(debugString);
}
if (!configurations.length) {
configurations = [releaseString, debugString];
}
var remotePlatform = path.resolve(".", "remote", platform.platform);
return tacoUtility.PromisesUtils.chain(configurations, function (configuration) {
var remotePlatformConfig = path.join(remotePlatform, configuration);
if (fs.existsSync(remotePlatformConfig)) {
logger.log(resources.getString("CleaningRemoteResources", platform.platform, configuration));
rimraf.sync(remotePlatformConfig);
}
return Q({});
});
default:
throw errorHelper.get(TacoErrorCodes.CommandBuildInvalidPlatformLocation, platform.platform);
}
return Q({});
};
return CleanHelper;
}());
exports.CleanHelper = CleanHelper;
//# sourceMappingURL=cleanHelper.js.map