Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

read-bsconfig

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-bsconfig - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

26

index.js

@@ -5,4 +5,8 @@ const { readFile, readFileSync } = require('fs')

function readBsConfig(cwd = process.cwd()) {
return new Promise((resolve, reject) => {
let asyncConfigCache = {}
function readBsConfig(cwd = process.cwd(), enableCache = true) {
if (asyncConfigCache[cwd] && enableCache) return asyncConfigCache[cwd]
asyncConfigCache[cwd] = new Promise((resolve, reject) => {
readFile(path.join(cwd, 'bsconfig.json'), (err, res) => {

@@ -14,10 +18,22 @@ if (err) return reject(err)

})
return asyncConfigCache[cwd]
}
function readBsConfigSync(cwd = process.cwd()) {
let syncConfigCache = {}
function readBsConfigSync(cwd = process.cwd(), enableCache = true) {
if (syncConfigCache[cwd] && enableCache) return syncConfigCache[cwd]
const content = readFileSync(path.join(cwd, 'bsconfig.json'))
syncConfigCache[cwd] = JSON5.parse(content.toString())
return JSON5.parse(content.toString())
return syncConfigCache[cwd]
}
module.exports = { readBsConfig, readBsConfigSync }
function clearCache() {
asyncConfigCache = {}
syncConfigCache = {}
}
module.exports = { readBsConfig, readBsConfigSync, clearCache }

2

package.json
{
"name": "read-bsconfig",
"version": "1.0.1",
"version": "1.0.2",
"description": "Library for reading the bsconfig.json for BuckleScript",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,3 +8,3 @@ # read-bsconfig

```js
const readBsConfig = require('read-bsconfig')
const { readBsConfig, readBsConfigSync } = require('read-bsconfig')

@@ -16,2 +16,10 @@ // Read from the CWD

const otherConf = readBsConfig(__dirname)
// A bsconfig for a given path will be cached. This can be turned off
// by passing a second parameter as false
const notCachedConf = readBsConfig(__dirname, false)
// You can also read a config sync
// It has a the same arguments
const mySyncConf = readBsConfigSync()
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc