-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathindex.js
72 lines (64 loc) · 2.21 KB
/
index.js
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
69
70
71
72
var RSVP = require('rsvp');
var glob = require('glob');
var DeployPluginBase = require('ember-cli-deploy-plugin');
var path = require('path');
module.exports = {
name: require('./package').name,
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');
if (process.env.EMBER_CLI_DEPLOY_REUSE_BUILD) {
this.log('reusing build from `' + outputPath, { verbose: true });
return RSVP.resolve({
distDir: outputPath,
distFiles: glob.sync('**/*', { cwd: outputPath, nodir: true , dot: true})
});
}
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 + '`...', { verbose: true });
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 RSVP.reject(error);
});
},
_logSuccess: function(outputPath) {
var self = this;
var files = glob.sync('**/**/*', { nonull: false, nodir: true, cwd: outputPath , dot: true});
if (files && files.length) {
files.forEach(function(path) {
self.log('✔ ' + path, { verbose: true });
});
}
self.log('build ok', { verbose: true });
return RSVP.resolve(files);
}
});
return new DeployPlugin();
}
};