-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.js
23 lines (22 loc) · 914 Bytes
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const fs = require('fs-extra');
const path = require('path');
const process = require('process');
const dayjs = require('dayjs');
const { repo } = require('./config');
const { exec } = require('./utils');
void async function () {
let deployPath = path.join(__dirname, '.deploy_git');
console.log('clean .deploy_git folder');
await fs.emptyDir(deployPath);
await fs.copy(path.join(__dirname, 'public'), deployPath);
try{
await exec(`git clone ${repo} repo`);
await fs.copy(path.join(__dirname, 'repo/.git/'), path.join(deployPath, '.git'));
process.chdir(deployPath);
await exec('git add .');
await exec(`git commit -m "updated: ${dayjs().format('YYYY-MM-DD dddd HH:mm:ss')}"`);
await exec('git push -u origin master');
await fs.remove(path.join(__dirname, 'repo'));
console.log('发布成功!');
}catch(e){console.log(e)}
}()