-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.mjs
31 lines (28 loc) · 1.07 KB
/
publish.mjs
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
import fs from "fs"
import path from "path"
const target = path.join("..", "extensions-jira-search-self-hosted", "extensions", "jira-search-self-hosted")
const ignoreList = [".git", ".idea", "node_modules"]
const shouldIgnore = (item) => ignoreList.findIndex((ignoreItem) => item === ignoreItem) > -1
function copy(item) {
const copyFile = () => {
console.log(`copying file ${item}`)
fs.copyFileSync(item, path.join(target, item))
}
const copyDir = () => {
console.log(`copying directory ${item}`)
fs.cpSync(item, path.join(target, item), { recursive: true })
}
if (fs.statSync(item).isDirectory()) copyDir()
else if (fs.statSync(item).isFile()) copyFile()
else console.warn(`ignored item ${item}`)
}
// prepare target directory
if (fs.existsSync(target)) {
console.log(`cleaning target directory ${target}`)
fs.rmSync(target, { force: true, recursive: true })
}
console.log(`creating target directory ${target}`)
fs.mkdirSync(target)
// copy items
const items = fs.readdirSync(".").filter((item) => !shouldIgnore(item))
items.forEach((item) => copy(item))