configparser
Advanced tools
| version: 2 | ||
| defaults: &defaults | ||
| working_directory: ~/repo | ||
| docker: | ||
| - image: circleci/node:10.6.0 | ||
| jobs: | ||
| test: | ||
| <<: *defaults | ||
| steps: | ||
| - checkout | ||
| - run: | ||
| name: Install dependencies | ||
| command: npm install | ||
| - run: | ||
| name: Run tests | ||
| command: npm test | ||
| - persist_to_workspace: | ||
| root: ~/repo | ||
| paths: . | ||
| deploy: | ||
| <<: *defaults | ||
| steps: | ||
| - attach_workspace: | ||
| at: ~/repo | ||
| - run: | ||
| name: Authenticate with registry | ||
| command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | ||
| - run: | ||
| name: Publish to npm | ||
| command: npm publish | ||
| deploy-docs: | ||
| <<: *defaults | ||
| steps: | ||
| - attach_workspace: | ||
| at: ~/repo | ||
| - add_ssh_keys: | ||
| fingerprints: | ||
| - "8c:9a:3f:98:cd:c9:1e:c8:ec:0b:0c:3e:1e:48:51:96" | ||
| - run: | ||
| name: Install dependencies | ||
| command: sudo npm install -g jsdoc gh-pages | ||
| - run: | ||
| name: Build docs | ||
| command: jsdoc -c jsdoc.json | ||
| - run: | ||
| name: Configure git | ||
| command: | | ||
| git config user.email "$GH_EMAIL" | ||
| git config user.name "$GH_NAME" | ||
| - run: | ||
| name: Deploy docs | ||
| command: gh-pages --dist docs/ | ||
| workflows: | ||
| version: 2 | ||
| test-deploy: | ||
| jobs: | ||
| - test: | ||
| filters: | ||
| tags: | ||
| only: /^v.*/ | ||
| branches: | ||
| ignore: /.*/ | ||
| - deploy: | ||
| requires: | ||
| - test | ||
| filters: | ||
| tags: | ||
| only: /^v.*/ | ||
| branches: | ||
| ignore: /.*/ | ||
| test-deploy-docs: | ||
| jobs: | ||
| - test: | ||
| filters: | ||
| branches: | ||
| only: master | ||
| - deploy-docs: | ||
| requires: | ||
| - test | ||
| filters: | ||
| branches: | ||
| only: master |
+4
-2
| { | ||
| "name": "configparser", | ||
| "version": "0.2.6", | ||
| "version": "0.3.6", | ||
| "description": "A basic config parser language based off the Python ConfigParser module.", | ||
@@ -23,3 +23,5 @@ "main": "src/configparser.js", | ||
| ], | ||
| "dependencies": {}, | ||
| "dependencies": { | ||
| "mkdirp": "^0.5.1" | ||
| }, | ||
| "devDependencies": { | ||
@@ -26,0 +28,0 @@ "chai": "^4.1.2", |
+44
-6
| const util = require('util'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const mkdirp = require('mkdirp'); | ||
| const errors = require('./errors'); | ||
@@ -35,2 +37,4 @@ const interpolation = require('./interpolation'); | ||
| const writeFileAsync = util.promisify(fs.writeFile); | ||
| const statAsync = util.promisify(fs.stat); | ||
| const mkdirAsync = util.promisify(mkdirp); | ||
@@ -218,6 +222,10 @@ /** | ||
| * @param {string|Buffer|int} file - Filename or File Descriptor | ||
| * @param {bool} [createMissingDirs=false] - Whether to create the directories in the path if they don't exist | ||
| */ | ||
| ConfigParser.prototype.write = function(file) { | ||
| const out = getSectionsAsString.call(this); | ||
| fs.writeFileSync(file, out); | ||
| ConfigParser.prototype.write = function(file, createMissingDirs = false) { | ||
| if (createMissingDirs) { | ||
| ensureDirectoriesExist(file); | ||
| } | ||
| fs.writeFileSync(file, getSectionsAsString.call(this)); | ||
| }; | ||
@@ -229,7 +237,11 @@ | ||
| * @param {string|Buffer|int} file - Filename or File Descriptor | ||
| * @param {bool} [createMissingDirs=false] - Whether to create the directories in the path if they don't exist | ||
| * @returns {Promise} | ||
| */ | ||
| ConfigParser.prototype.writeAsync = function(file) { | ||
| const out = getSectionsAsString.call(this); | ||
| return writeFileAsync(file, out); | ||
| ConfigParser.prototype.writeAsync = async function(file, createMissingDirs = false) { | ||
| if (createMissingDirs) { | ||
| await ensureDirectoriesExistAsync(file); | ||
| } | ||
| await writeFileAsync(file, getSectionsAsString.call(this)); | ||
| } | ||
@@ -278,2 +290,28 @@ | ||
| function ensureDirectoriesExist(filePath) { | ||
| const dir = path.dirname(filePath); | ||
| try { | ||
| fs.statSync(dir); | ||
| } catch (err) { | ||
| if (err.code === 'ENOENT') { | ||
| mkdirp.sync(dir); | ||
| } else { | ||
| throw err; | ||
| } | ||
| } | ||
| } | ||
| async function ensureDirectoriesExistAsync(filePath) { | ||
| const dir = path.dirname(filePath); | ||
| try { | ||
| await statAsync(dir); | ||
| } catch (err) { | ||
| if (err.code === 'ENOENT') { | ||
| await mkdirAsync(dir); | ||
| } else { | ||
| throw err; | ||
| } | ||
| } | ||
| } | ||
| module.exports = ConfigParser; |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
21888
16.56%8
14.29%474
7.73%1
Infinity%+ Added
+ Added
+ Added