-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpublish.js
More file actions
executable file
·55 lines (42 loc) · 1.15 KB
/
publish.js
File metadata and controls
executable file
·55 lines (42 loc) · 1.15 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
#!/usr/bin/env node
'use strict'
/**
* Dependencies
*/
const ghpages = require('gh-pages');
const Path = require('path');
const resolve = require(`${__dirname}/util/resolve`);
const cnsl = require(`${__dirname}/util/console`);
const config = resolve('config/publish');
const alerts = resolve('config/alerts');
const global = resolve('config/global');
/**
* Constants
*/
const dist = Path.join(global.base, global.dist);
const remote = (process.env.NODE_ENV === 'production')
? 'origin' : process.env.NODE_ENV;
/**
* Functions
*/
const main = () => {
if (undefined === remote) {
cnsl.notify(`${alerts.info} Can't publish. Set ${alerts.str.ext('process.env.NODE_ENV')} to the desired remote defined in ${alerts.str.path('config/publish.js')}`);
process.exit();
}
cnsl.describe(`${alerts.info} Publishing to ${remote}; ${config[process.env.NODE_ENV]}`);
ghpages.publish(dist, {
remote: remote,
repo: config[process.env.NODE_ENV]
}, err => {
if (err) {
cnsl.error(`Publish (main): ${err.stack}`);
} else {
cnsl.success('Published to GitHub Pages');
}
});
};
module.exports = {
main: main,
run: main
};