1 | const fs = require('fs')
|
2 | const cwd = process.cwd()
|
3 | const path = require('path')
|
4 | const { log } = require('./log')
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | module.exports = () => {
|
13 | let packageJson
|
14 | try {
|
15 | packageJson = require(path.posix.join(cwd, 'package.json'))
|
16 | } catch (err) {
|
17 | if (err.code === 'MODULE_NOT_FOUND') {
|
18 | log('Please init package.json!\nPlease init package.json!\nPlease init package.json!', 'red')
|
19 | log('Sorry, important things should be mentioned three times...')
|
20 | process.exit(1)
|
21 | } else {
|
22 | throw err
|
23 | }
|
24 | }
|
25 |
|
26 | if (!fs.existsSync(path.posix.join(cwd, '.git'))) {
|
27 | log('Please init git!\nPlease init git!\nPlease init git!', 'red')
|
28 | log('Sorry, important things should be mentioned three times...')
|
29 | process.exit(1)
|
30 | }
|
31 | }
|