-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy-script.js
More file actions
23 lines (22 loc) · 849 Bytes
/
Copy pathdeploy-script.js
File metadata and controls
23 lines (22 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const execa = require('execa');
const fs = require('fs');
(async () => {
try {
await execa('git', ['checkout', '--orphan', 'master']);
console.log('Building...');
await execa('npm', ['run', 'build']);
// Understand if it's dist or build folder
const folderName = fs.existsSync('dist') ? 'dist' : 'build';
await execa('git', ['--work-tree', folderName, 'add', '--all']);
await execa('git', ['--work-tree', folderName, 'commit', '-m', 'master']);
console.log('Pushing to master...');
await execa('git', ['push', 'origin', 'master', '--force']);
await execa('rm', ['-r', folderName]);
await execa('git', ['checkout', '-f', 'develop']);
await execa('git', ['branch', '-D', 'master']);
console.log('Successfully deployed');
} catch (e) {
console.log(e.message);
process.exit(1);
}
})();