This repository was archived by the owner on Jun 20, 2022. It is now read-only.
forked from ember-cli-deploy/ember-cli-deploy-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
68 lines (59 loc) · 1.91 KB
/
index.js
File metadata and controls
68 lines (59 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* jshint node: true */
'use strict';
var Promise = require('ember-cli/lib/ext/promise');
var glob = require('glob');
var DeployPluginBase = require('ember-cli-deploy-plugin');
var path = require('path');
module.exports = {
name: 'ember-cli-deploy-build',
createDeployPlugin: function(options) {
var DeployPlugin = DeployPluginBase.extend({
name: options.name,
defaultConfig: {
environment: 'production',
outputPath: 'tmp' + path.sep + 'deploy-dist'
},
build: function(context) {
var self = this;
var outputPath = this.readConfig('outputPath');
var buildEnv = this.readConfig('environment');
var Builder = this.project.require('ember-cli/lib/models/builder');
var builder = new Builder({
ui: this.ui,
outputPath: outputPath,
environment: buildEnv,
project: this.project
});
this.log('building app to `' + outputPath + '` using buildEnv `' + buildEnv + '`...');
return builder.build()
.finally(function() {
return builder.cleanup();
})
.then(this._logSuccess.bind(this, outputPath))
.then(function(files) {
files = files || [];
return {
distDir: outputPath,
distFiles: files
};
})
.catch(function(error) {
self.log('build failed', { color: 'red' });
return Promise.reject(error);
});
},
_logSuccess: function(outputPath) {
var self = this;
var files = glob.sync('**/**/*', { nonull: false, nodir: true, cwd: outputPath });
if (files && files.length) {
files.forEach(function(path) {
self.log('✔ ' + path);
});
}
self.log('build ok');
return Promise.resolve(files);
}
});
return new DeployPlugin();
}
};