This repository has been archived by the owner on Oct 31, 2022. It is now read-only.
forked from ember-cli-deploy/ember-cli-deploy-revision-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (46 loc) · 1.44 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
/* jshint node: true */
'use strict';
var Promise = require('ember-cli/lib/ext/promise');
var DeployPluginBase = require('ember-cli-deploy-plugin');
module.exports = {
name: 'ember-cli-deploy-revision-data',
createDeployPlugin: function(options) {
var DeployPlugin = DeployPluginBase.extend({
name: options.name,
defaultConfig: {
type: 'file-hash',
filePattern: 'index.html',
distDir: function(context) {
return context.distDir;
},
distFiles: function(context) {
return context.distFiles;
},
versionFile: 'package.json',
},
prepare: function(context) {
var self = this;
var type = this.readConfig('type');
var DataGenerator = require('./lib/data-generators')[type];
var dataGenerator = new DataGenerator({
plugin: this
});
this.log('creating revision data using `' + type + '`');
return dataGenerator.generate()
.then(function(data) {
self.log('generated revision data for revision: `' + data.revisionKey + '`');
return data;
})
.then(function(data) {
return { revisionData: data };
})
.catch(this._errorMessage.bind(this));
},
_errorMessage: function(error) {
this.log(error, { color: 'red' });
return Promise.reject(error);
}
});
return new DeployPlugin();
}
};