Skip to content

Commit f913299

Browse files
committed
refactor(tasks): drop legacy prepare() pattern
1 parent 920e501 commit f913299

File tree

6 files changed

+9
-24
lines changed

6 files changed

+9
-24
lines changed

lib/commands/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ module.exports = Command.extend({
9090
return cordovaTarget.build();
9191
}
9292
})
93-
.then(hook.prepare('afterBuild', options))
93+
.then(() => hook.run('afterBuild', options))
9494
.then(() => lint.run())
9595
.then(function() {
9696
logger.success('ember-cordova project built');

lib/commands/prepare.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ module.exports = Command.extend({
2525
});
2626

2727
return hook.run('beforePrepare', options)
28-
.then(prepare.prepare())
29-
.then(hook.prepare('afterPrepare', options))
28+
.then(() => prepare.run())
29+
.then(() => hook.run('afterPrepare', options))
3030
.catch(function(err) {
3131
logger.error(err);
3232
});

lib/commands/serve.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ module.exports = Command.extend({
7878
return editXml.addNavigation(project, reloadUrl)
7979
.then(() => cordovaTarget.validateServe())
8080
.then(() => framework.validateServe(opts))
81-
.then(hook.prepare('beforeBuild', opts))
82-
.then(setupLivereload.prepare(reloadUrl))
81+
.then(() => hook.run('beforeBuild', opts))
82+
.then(() => setupLivereload.run(reloadUrl))
8383
.then(function() {
8484
if (opts.skipCordovaBuild !== true) {
8585
return cordovaTarget.build();
8686
}
8787
})
88-
.then(hook.prepare('afterBuild', opts))
88+
.then(() => hook.run('afterBuild', opts))
8989
.then(function() {
9090
if (opts.skipFrameworkBuild !== true) {
9191
return framework.serve(opts, ui);

lib/frameworks/vue/tasks/build.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module.exports = Task.extend({
1919
command: `cp -R ${this.buildPath}/* ${this.cordovaOutputPath}`
2020
});
2121

22-
return build.run()
23-
.then(copy.prepare());
22+
return build.run().then(() => copy.run());
2423
}
2524
});

lib/tasks/-task.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
11
const Task = require('ember-cli/lib/models/task');
22

3-
module.exports = Task.extend({
4-
prepare() {
5-
let task = this;
6-
let args = Array.prototype.slice.call(arguments);
7-
8-
return function preparedTask() {
9-
return task.run.apply(task, args);
10-
};
11-
}
12-
});
3+
module.exports = Task.extend();

node-tests/unit/frameworks/vue/tasks/build-test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ describe('Vue Build Task', function() {
1616
return Promise.resolve();
1717
});
1818

19-
td.replace(Bash.prototype, 'prepare', function() {
20-
tasks.push('bash-task-2');
21-
return Promise.resolve();
22-
});
23-
2419
buildTask = new Build({
2520
buildCommand: 'fakeBuildCommand',
2621
buildPath: 'fakePath',
@@ -36,7 +31,7 @@ describe('Vue Build Task', function() {
3631
return buildTask.run({cordovaOutputPath: 'fakePath'}).then(function() {
3732
expect(tasks).to.deep.equal([
3833
'bash-task',
39-
'bash-task-2'
34+
'bash-task'
4035
]);
4136
});
4237
});

0 commit comments

Comments
 (0)