-
Notifications
You must be signed in to change notification settings - Fork 1
/
publish.js
45 lines (37 loc) · 1007 Bytes
/
publish.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
var fs = require("vinyl-fs");
var ftp = require("vinyl-ftp");
var ftpConfig = require("./.ftpconfig.js");
var colors = require('chalk');
require('dotenv').config();
var version = require("./version.js");
require('child_process').execSync("echo " + version + " > public/version.txt");
const paths = {
upload: {
dest: ftpConfig.path,
base: "./public",
globs: [
'public/**',
'!public/conf.php',
'!public/setuser.php',
'!public/conf.php.sample',
'!public/user-auth.php',
'!public/setuser-test.php',
'!public/helper/Classes/vendor/**'
]
}
};
if (process.env.SAFE_TO_PUBLISH === 'true') {
var conn = new ftp(ftpConfig);
fs.src(
paths.upload.globs,
{
buffer: false
})
.pipe(conn.newer(paths.upload.dest))
.pipe(conn.dest(paths.upload.dest)
);
// Update sitemap
require("./generate-sitemap.js");
} else {
console.log(colors.red("Publishing are prohibited by env-var 'SAFE_TO_PUBLISH', check file .env"));
}