Repository: cordova-windows Updated Branches: refs/heads/4.4.x f8479e5da -> 1299ade53
CB-11579 windows: fix bug with 'cordova clean windows' This closes #189 Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/3db92496 Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/3db92496 Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/3db92496 Branch: refs/heads/4.4.x Commit: 3db92496f2ccd6c4260085fda84efa2c63232827 Parents: f8479e5 Author: Nikita Matrosov <[email protected]> Authored: Wed Jul 27 18:12:56 2016 +0300 Committer: daserge <[email protected]> Committed: Thu Oct 20 20:54:52 2016 +0300 ---------------------------------------------------------------------- spec/unit/clean.spec.js | 46 +++++++++++++++++++ spec/unit/fixtures/DummyProject/config.xml | 1 + .../images/SplashScreen.scale-100.png | Bin 0 -> 24855 bytes template/cordova/lib/prepare.js | 2 +- 4 files changed, 48 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/3db92496/spec/unit/clean.spec.js ---------------------------------------------------------------------- diff --git a/spec/unit/clean.spec.js b/spec/unit/clean.spec.js new file mode 100644 index 0000000..c969141 --- /dev/null +++ b/spec/unit/clean.spec.js @@ -0,0 +1,46 @@ +var shell = require('shelljs'), + path = require('path'), + fs = require('fs'), + prepareModule = require('../../template/cordova/lib/prepare'), + DUMMY_PROJECT_PATH = path.join(__dirname, '/fixtures/DummyProject'), + iconPath, currentProject; + +describe('Cordova clean command', function() { + beforeEach(function() { + shell.cp('-rf', DUMMY_PROJECT_PATH, __dirname); + currentProject = path.join(__dirname, 'DummyProject'); + iconPath = path.join(currentProject, 'images/SplashScreen.scale-100.png'); + + var fsExistsSyncOrig = fs.existsSync; + spyOn(fs, 'existsSync').andCallFake(function (filePath) { + if (/config\.xml$/.test(filePath)) return true; + return fsExistsSyncOrig(filePath); + }); + }); + + afterEach(function() { + shell.rm('-rf', currentProject); + }); + + it('spec 1. should remove icons when ran inside Cordova project', function(done) { + var config = { + platform: 'windows', + root: currentProject, + locations: { + root: currentProject, + configXml: path.join(currentProject, 'config.xml'), + www: path.join(currentProject, 'www') + } + }; + + var rejected = jasmine.createSpy(); + prepareModule.clean.call(config) + .then(function() { + expect(fs.existsSync(iconPath)).toBeFalsy(); + }, rejected) + .finally(function() { + expect(rejected).not.toHaveBeenCalled(); + done(); + }); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/3db92496/spec/unit/fixtures/DummyProject/config.xml ---------------------------------------------------------------------- diff --git a/spec/unit/fixtures/DummyProject/config.xml b/spec/unit/fixtures/DummyProject/config.xml index 621d9c9..279ba82 100644 --- a/spec/unit/fixtures/DummyProject/config.xml +++ b/spec/unit/fixtures/DummyProject/config.xml @@ -9,6 +9,7 @@ <author email="[email protected]" href="http://cordova.io"> Apache Cordova Team </author> + <icon src="images/SplashScreen.scale-100.png" width="620" height="300"></icon> <content src="index.html" /> <access origin="*" /> </widget> http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/3db92496/spec/unit/fixtures/DummyProject/images/SplashScreen.scale-100.png ---------------------------------------------------------------------- diff --git a/spec/unit/fixtures/DummyProject/images/SplashScreen.scale-100.png b/spec/unit/fixtures/DummyProject/images/SplashScreen.scale-100.png new file mode 100644 index 0000000..d1e6c98 Binary files /dev/null and b/spec/unit/fixtures/DummyProject/images/SplashScreen.scale-100.png differ http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/3db92496/template/cordova/lib/prepare.js ---------------------------------------------------------------------- diff --git a/template/cordova/lib/prepare.js b/template/cordova/lib/prepare.js index 2d3a9c9..0067803 100644 --- a/template/cordova/lib/prepare.js +++ b/template/cordova/lib/prepare.js @@ -484,7 +484,7 @@ module.exports.clean = function (options) { var self = this; return Q().then(function () { cleanWww(projectRoot, self.locations); - cleanImages(projectRoot, projectConfig); + cleanImages(projectRoot, projectConfig, self.locations); }); }; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
