forked from sethwebster/ember-cli-new-version
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (44 loc) · 1.35 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
/* eslint-env node */
'use strict';
const writeFile = require('broccoli-file-creator');
module.exports = {
name: require('./package').name,
/**
* Setup default configuration options and auto detect the currentVersion if it isn't set manually
*/
config(env, baseConfig) {
const defaultConfiguration = {
versionFileName: 'VERSION.txt',
firstCheckInterval: 0,
updateInterval: 60000,
enableInTests: false,
enableInDev: false,
maxCountInTesting: 10,
};
baseConfig.newVersion = Object.assign(
defaultConfiguration,
baseConfig.newVersion
);
if (!baseConfig.newVersion.currentVersion) {
if (baseConfig.APP.version) {
//if `ember-cli-app-version` is installed use the detected version from that addon
baseConfig.newVersion.currentVersion = baseConfig.APP.version;
} else {
//otherwise use what is in package.json.
baseConfig.newVersion.currentVersion = this.parent.pkg.version;
}
}
this._config = baseConfig.newVersion;
return baseConfig;
},
/**
* Write version file
*/
treeForPublic() {
const { currentVersion, versionFileName } = this._config;
if (currentVersion) {
this.ui.writeLine(`Created ${versionFileName} with ${currentVersion}`);
return writeFile(versionFileName, currentVersion);
}
},
};