Skip to content

Commit 21e955f

Browse files
authored
Merge pull request #425 from jelhan/fix-cordova-output-path
Fix: cordova build does not respect cordovaOutputPath when calling LintIndex
2 parents dbf6b1a + 450cc1f commit 21e955f

File tree

5 files changed

+140
-88
lines changed

5 files changed

+140
-88
lines changed

lib/commands/build.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ module.exports = Command.extend({
6363
project: this.project
6464
});
6565

66+
let indexHtmlPath = path.join(options.cordovaOutputPath, 'index.html');
67+
6668
let lint = new LintIndex({
67-
source: 'www/index.html',
68-
project: this.project
69+
source: indexHtmlPath
6970
});
7071

7172
let addCordovaJS = new AddCordovaJS({
72-
source: path.join(options.cordovaOutputPath, 'index.html')
73+
source: indexHtmlPath
7374
});
7475

7576
let framework = requireFramework(this.project);

lib/commands/lint-index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const Command = require('./-command');
2+
const cordovaPath = require('../targets/cordova/utils/get-path');
23
const Lint = require('../tasks/lint-index');
4+
const path = require('path');
35

46
module.exports = Command.extend({
57
name: 'lint-index',
@@ -16,8 +18,7 @@ module.exports = Command.extend({
1618
this._super.apply(this, arguments);
1719

1820
let lint = new Lint({
19-
source: options.source,
20-
project: this.project
21+
source: path.join(cordovaPath(this.project), options.source)
2122
});
2223

2324
return lint.run();

lib/tasks/lint-index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
const Task = require('./-task');
22
const HTMLParser = require('htmlparser2').Parser;
33
const Promise = require('rsvp').Promise;
4-
const path = require('path');
54
const fsUtils = require('../utils/fs-utils');
6-
const cordovaPath = require('../targets/cordova/utils/get-path');
75
const logger = require('../utils/logger');
86

97
const ROOT_URL_PATTERN = /^\//;
@@ -78,8 +76,7 @@ module.exports = Task.extend({
7876
},
7977

8078
run() {
81-
let projectPath = cordovaPath(this.project);
82-
let indexPath = path.join(projectPath, this.source);
79+
let indexPath = this.source;
8380

8481
logger.info('corber : Linting ' + indexPath + '...\n');
8582

node-tests/unit/commands/build-test.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,21 @@ describe('Build Command', function() {
161161
let build = setupBuild();
162162
return build.run(baseOpts).then(function() {
163163
td.verify(new LintTask({
164-
source: 'www/index.html',
165-
project: mockProject.project
164+
source: 'corber/cordova/www/index.html',
165+
}));
166+
});
167+
});
168+
169+
it('supports custom output path with --cordova-output-path option', function() {
170+
let build = setupBuild();
171+
baseOpts.cordovaOutputPath = 'foo';
172+
173+
return build.run(baseOpts).then(function() {
174+
td.verify(new AddCordovaJS({
175+
source: 'foo/index.html'
176+
}));
177+
td.verify(new LintTask({
178+
source: 'foo/index.html'
166179
}));
167180
});
168181
});

0 commit comments

Comments
 (0)