Skip to content

Commit 1cd3c9d

Browse files
author
Aaron Chambers
committed
Merge pull request #6 from strange-studios/improve-context-data-output
Now we don't make a distinction between index and assets
2 parents bce636e + 3f6169b commit 1cd3c9d

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

index.js

+33-23
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
/* jshint node: true */
22
'use strict';
33

4-
var chalk = require('chalk');
4+
var Promise = require('ember-cli/lib/ext/promise');
5+
56
var glob = require('glob');
7+
var chalk = require('chalk');
8+
var blue = chalk.blue;
69

710
module.exports = {
811
name: 'ember-cli-deploy-build',
912

1013
createDeployPlugin: function(options) {
11-
function pipelineData(outputPath) {
12-
var data = {};
14+
function _beginMessage(ui, outputPath) {
15+
ui.write(blue('| '));
16+
ui.writeLine(blue('- building into `' + outputPath + '`'));
1317

14-
var files = glob.sync(outputPath + '/index.html', { nonull: false });
15-
16-
if (files && files.length) {
17-
data.indexPath = files[0];
18-
}
18+
return Promise.resolve();
19+
}
1920

20-
files = glob.sync(outputPath + '**/**/*', { nonull: false, ignore: '**/index.html' });
21+
function _successMessages(ui, outputPath) {
22+
var files = glob.sync(outputPath + '**/**/*', { nonull: false, nodir: true });
2123

2224
if (files && files.length) {
23-
data.assetPaths = files;
25+
files.forEach(function(path) {
26+
ui.write(blue('| '));
27+
ui.writeLine(blue('- ' + path));
28+
});
2429
}
2530

26-
return data;
31+
ui.write(blue('| '));
32+
ui.writeLine(blue('- build successful'));
33+
34+
return Promise.resolve(files);
2735
}
2836

2937
return {
@@ -38,8 +46,6 @@ module.exports = {
3846
var outputPath = 'dist';
3947
var buildEnv = config.buildEnv || 'production';
4048

41-
ui.startProgress(chalk.green('Building'), chalk.green('.'));
42-
4349
var Builder = require('ember-cli/lib/models/builder');
4450
var builder = new Builder({
4551
ui: ui,
@@ -48,21 +54,25 @@ module.exports = {
4854
project: project
4955
});
5056

51-
return builder.build()
57+
return _beginMessage(ui, outputPath)
58+
.then(builder.build.bind(builder))
5259
.finally(function() {
53-
ui.stopProgress();
5460
return builder.cleanup();
5561
})
56-
.then(function() {
57-
ui.writeLine(chalk.green('Built project successfully. Stored in "' +
58-
outputPath + '".'));
62+
.then(_successMessages.bind(this, ui, outputPath))
63+
.then(function(files) {
64+
files = files || [];
65+
66+
return {
67+
distDir: outputPath,
68+
distFiles: files
69+
};
5970
})
60-
.then(pipelineData.bind(this, outputPath))
61-
.catch(function(err) {
62-
ui.writeLine(chalk.red('Build failed.'));
63-
ui.writeError(err);
71+
.catch(function(error) {
72+
ui.write(blue('| '));
73+
ui.writeLine(chalk.red('build failed'));
6474

65-
return 1;
75+
return Promise.reject(error);
6676
});
6777
}
6878
}

0 commit comments

Comments
 (0)