1 | #! /usr/bin/env node
|
2 |
|
3 | var fs = require('fs')
|
4 | var mkdirp = require('mkdirp')
|
5 | var path = require('path')
|
6 |
|
7 | var currentPath = process.cwd()
|
8 | var configPath = path.join(__dirname, '../config/config.development.json.sample')
|
9 | var destinationDir = path.join(currentPath, '../../../config')
|
10 | var destinationFile = path.join(destinationDir, 'config.development.json')
|
11 |
|
12 |
|
13 | if (~currentPath.indexOf('node_modules')) {
|
14 |
|
15 | mkdirp(destinationDir, (err, made) => {
|
16 | if (err) throw err
|
17 |
|
18 | fs.stat(destinationFile, (err, stats) => {
|
19 | if (err && err.code && err.code === 'ENOENT') {
|
20 |
|
21 | fs.readFile(configPath, (err, data) => {
|
22 | if (err) throw err
|
23 |
|
24 | fs.writeFile(destinationFile, data, (err) => {
|
25 | if (err) throw err
|
26 |
|
27 | console.log('API configuration created at', destinationFile)
|
28 | })
|
29 | })
|
30 | }
|
31 | })
|
32 | })
|
33 | }
|