CB-11579 windows: fix bug with 'cordova clean windows'
This closes #189
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();
+ });
+ });
+});
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="dev@cordova.apache.org" 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>
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
--- /dev/null
+++ b/spec/unit/fixtures/DummyProject/images/SplashScreen.scale-100.png
Binary files differ
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 @@
var self = this;
return Q().then(function () {
cleanWww(projectRoot, self.locations);
- cleanImages(projectRoot, projectConfig);
+ cleanImages(projectRoot, projectConfig, self.locations);
});
};