mirror of
https://github.com/jlengrand/coffeechat.git
synced 2026-03-10 08:11:20 +00:00
make the script works from any folder
This commit is contained in:
29
scripts/package-lock.json
generated
Normal file
29
scripts/package-lock.json
generated
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "scripts",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"devDependencies": {
|
||||
"app-root-path": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/app-root-path": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-3.0.0.tgz",
|
||||
"integrity": "sha512-qMcx+Gy2UZynHjOHOIXPNvpf+9cjvk3cWrBBK7zg4gH9+clobJRb9NGzcT7mQTcV/6Gm/1WelUtqxVXnNlrwcw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"app-root-path": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-3.0.0.tgz",
|
||||
"integrity": "sha512-qMcx+Gy2UZynHjOHOIXPNvpf+9cjvk3cWrBBK7zg4gH9+clobJRb9NGzcT7mQTcV/6Gm/1WelUtqxVXnNlrwcw==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
5
scripts/package.json
Normal file
5
scripts/package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"app-root-path": "^3.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
'use strict;'
|
||||
const fs = require('fs');
|
||||
const appRoot = require('app-root-path');
|
||||
let path = require('path');
|
||||
|
||||
//Get the data
|
||||
const data = fs.readFileSync('../people.json');
|
||||
path = path.parse(appRoot.path);
|
||||
parentFolderPath = path.dir.split(path.sep).pop();
|
||||
const data = fs.readFileSync(`${parentFolderPath}/people.json`);
|
||||
const json = JSON.parse(data);
|
||||
|
||||
//Order by name
|
||||
@@ -16,5 +20,5 @@ const peopleList = json.people.map(people =>
|
||||
).join('\r\n');
|
||||
|
||||
//Write README.md
|
||||
const template = fs.readFileSync('README-TEMPLATE.md', 'utf8');
|
||||
fs.writeFileSync('../README.md', template.replace('PLACEHOLDER', peopleList));
|
||||
const template = fs.readFileSync(`${appRoot}/README-TEMPLATE.md`, 'utf8');
|
||||
fs.writeFileSync(`${parentFolderPath}/README.md`, template.replace('PLACEHOLDER', peopleList));
|
||||
|
||||
Reference in New Issue
Block a user