Skip to content

Commit 36267c6

Browse files
committed
Include postinstall script to setup github details
1 parent 588ab2f commit 36267c6

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

install/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const fs = require('fs');
2+
const inquirer = require('inquirer');
3+
4+
const utils = require('../src/utils');
5+
6+
async function install() {
7+
const authPath = utils.fs.resolvePath('~/auth.json');
8+
9+
const answers = await inquirer.prompt([
10+
{
11+
type: 'input',
12+
name: 'user',
13+
message: 'What is your github user?',
14+
},
15+
16+
{
17+
type: 'input',
18+
name: 'token',
19+
message: 'What is your GitHub token?',
20+
},
21+
]);
22+
23+
// Write file
24+
const data = {
25+
github: [
26+
{
27+
user: answers.user,
28+
token: answers.token,
29+
},
30+
],
31+
};
32+
33+
fs.writeFileSync(authPath, JSON.stringify(data));
34+
console.log(`File ${authPath} created with your github details`);
35+
}
36+
37+
install();

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"license": "MIT",
1919
"private": false,
2020
"scripts": {
21+
"postinstall": "node install/index.js",
2122
"start": "node src/index.js",
2223
"cleanup": "node test/cleanup.js"
2324
},

0 commit comments

Comments
 (0)