-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
57 lines (51 loc) · 1.23 KB
/
gulpfile.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
const argv = require("yargs").argv
const path = require("path")
const gulp = require("gulp")
const zip = require("gulp-zip")
const del = require("del")
const replace = require("gulp-token-replace")
// Set environment variables
const env = argv.env
if (env === undefined) {
require("dotenv").config()
} else {
require("dotenv").config({ path: path.resolve(process.cwd(), env) })
}
const pre_clean = (cb) => {
return del(["./manifest/package/*.zip", "./temp"])
}
const post_clean = (cb) => {
return del(["./temp"])
}
const generateManifest = (cb) => {
return gulp
.src("./manifest/manifest.json")
.pipe(
replace({
tokens: {
...process.env,
},
}),
)
.pipe(gulp.dest("./temp"))
}
const zipTask = (cb) => {
// Get all png files (icons), json files (resources) but not the manifest.json from /src/manifest
const filePath = "./temp/manifest.json"
return (
gulp
.src(["./manifest/*.png"])
// get the manifest from the temp folder
.pipe(gulp.src(filePath))
.pipe(zip("teamsTab.zip"))
.pipe(gulp.dest("./manifest/package"))
)
}
gulp.task(
"manifest",
gulp.series(pre_clean, generateManifest, zipTask, post_clean),
function (done) {
console.log("Build completed. Output in manifest folder")
done()
},
)