1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | var fs = require('fs')
|
8 | , util = require('util')
|
9 | , crypto = require('crypto')
|
10 |
|
11 | var CONFIG_FILE = process.cwd() + '/config.json'
|
12 |
|
13 | function randomString () {
|
14 | return crypto.randomBytes( 8 ).toString( 'hex' )
|
15 | }
|
16 |
|
17 | if ( fs.existsSync( CONFIG_FILE ) ) {
|
18 | console.log('Using existing config.json')
|
19 | } else {
|
20 | console.log( 'Creating config.json' )
|
21 | var data = fs.readFileSync( __dirname + '/default.config.json' ).toString()
|
22 |
|
23 | data = data.replace( /XXX/g , randomString() )
|
24 | fs.writeFileSync( CONFIG_FILE, data )
|
25 | } |
\ | No newline at end of file |