diff --git a/scripts/package-lock.json b/scripts/package-lock.json new file mode 100644 index 0000000..9146a01 --- /dev/null +++ b/scripts/package-lock.json @@ -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 + } + } +} diff --git a/scripts/package.json b/scripts/package.json new file mode 100644 index 0000000..2a9b9fb --- /dev/null +++ b/scripts/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "app-root-path": "^3.0.0" + } +} diff --git a/scripts/write-readme.js b/scripts/write-readme.js index c778b75..e919105 100644 --- a/scripts/write-readme.js +++ b/scripts/write-readme.js @@ -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));