-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
30 lines (25 loc) · 819 Bytes
/
init.js
File metadata and controls
30 lines (25 loc) · 819 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
/*
* init script after git clone
*/
const { rmdirSync, readFileSync, writeFileSync, unlinkSync } = require('fs')
const { resolve } = require('path')
const { spawnSync } = require('child_process')
// remove `.git` directory
rmdirSync(resolve(__dirname, '.git'))
// remove lock file from .gitignore
const ignoreFile = resolve(__dirname, '.gitignore')
const fileContent = readFileSync(ignoreFile, 'utf8')
const newContent = fileContent
.split('\n')
.filter(line => !/(yarn\.lock|package-lock\.json)/.test(line))
.join('\n')
writeFileSync(ignoreFile, newContent)
// run git init
spawnSync('git', ['init'], { stdio: 'inherit', cwd: __dirname })
// remove the script itself
unlinkSync(__filename)
// finish
console.log(`Please run the following command:
1. cd clair-template-dashboard
2. yarn 或 npm install
`)