forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartifacts.js
More file actions
74 lines (61 loc) · 1.68 KB
/
artifacts.js
File metadata and controls
74 lines (61 loc) · 1.68 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const fs = require('fs')
const path = require('path')
const fse = require('fs-extra')
const appPaths = require('./app-paths')
const filePath = appPaths.resolve.app('.quasar/artifacts.json')
const { log } = require('./helpers/logger')
function exists () {
return fs.existsSync(filePath)
}
function getArtifacts () {
return exists()
? require(filePath)
: { folders: [] }
}
function save (content) {
fse.mkdirp(path.dirname(filePath))
fs.writeFileSync(filePath, JSON.stringify(content), 'utf-8')
}
module.exports.add = function (entry) {
const content = getArtifacts()
if (!content.folders.includes(entry)) {
content.folders.push(entry)
save(content)
log(`Added build artifact "${entry}"`)
}
}
module.exports.clean = function (folder) {
if (folder.endsWith(path.join('src-cordova', 'www'))) {
fse.emptyDirSync(folder)
}
else if (folder.endsWith(path.join('src-capacitor', 'www'))) {
fse.emptyDirSync(folder)
fse.copySync(
appPaths.resolve.cli('templates/capacitor/www'),
appPaths.capacitorDir
)
}
else {
fse.removeSync(folder)
}
log(`Cleaned build artifact: "${folder}"`)
}
module.exports.cleanAll = function () {
getArtifacts().folders.forEach(folder => {
if (folder.endsWith(path.join('src-cordova', 'www'))) {
fse.emptyDirSync(folder)
}
else {
fse.removeSync(folder)
}
log(`Cleaned build artifact: "${folder}"`)
})
let folder = appPaths.resolve.app('.quasar')
fse.removeSync(folder)
log(`Cleaned build artifact: "${folder}"`)
const distFolder = appPaths.resolve.app('dist')
if (fs.existsSync(distFolder)) {
fse.emptyDirSync(distFolder)
log(`Emptied dist folder`)
}
}