-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
42 lines (35 loc) · 879 Bytes
/
Copy pathbuild.js
File metadata and controls
42 lines (35 loc) · 879 Bytes
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
const { execSync } = require('child_process')
const fs = require('fs')
function run(cmd) {
execSync(cmd, { stdio: 'inherit' })
}
function removeDir(path) {
if (fs.existsSync(path)) {
fs.rmSync(path, { recursive: true, force: true })
console.log(`🗑️ Removido: ${path}`)
} else {
console.log(`ℹ️ Não existe: ${path}`)
}
}
function hasStagedChanges() {
try {
execSync('git diff --cached --quiet', { stdio: 'ignore' })
return false
} catch {
return true
}
}
console.log('🗑️ Limpando arquivos')
removeDir('.parcel-cache')
removeDir('docs')
removeDir('dist')
console.log('🤖 Criando build')
run('yarn build:parcel')
console.log('➕ Adicionando os arquivos')
run('git add .')
if (hasStagedChanges()) {
console.log('✅ Commit')
run('git commit -m "- Build deploy"')
} else {
console.log('ℹ️ Nada para commitar')
}