You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@qiwi/uniconfig-plugin-api-file

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qiwi/uniconfig-plugin-api-file

Uniconfig file API (fs) plugin

4.0.1
latest
Source
npmnpm
Version published
Maintainers
2
Created
Source

@qiwi/uniconfig-plugin-api-file

Uniconfig File API plugin

Install

  npm i @qiwi/uniconfig-plugin-api-file
  yarn add @qiwi/uniconfig-plugin-api-file

Usage

import uniconfig, {rollupPlugin} from '@qiwi/uniconfig-core'
import uniconfigFileApiPlugin from '@qiwi/uniconfig-plugin-api-file'
import uniconfigJsonParserPlugin from '@qiwi/uniconfig-plugin-parser-json'
    
rollupPlugin(uniconfigFileApiPlugin)
rollupPlugin(uniconfigJsonParserPlugin)

const target = './foo.json'
/** foo.json content:
{
  "foo": "bar"
}
*/

const config = uniconfig({
  data: {
    someParam: '$fromFile:foo'
  },
  source: {
    fromFile: {
      data: '<some path>',
      pipeline: 'file>json'
    }
  }
}, {
  mode: 'sync',
  pipeline: 'datatree'
})    

config.get('someParam') // "bar"

const missingTarget = './foo-missing.json' // this file does not exist
const target2 = './foo2.json'
/** foo2.json content:
 {
  "foo2": "bar2"
}
 */

const config = uniconfig({
  data: {
    someParam: '$fromFile:foo'
  },
  source: {
    fromFile: {
      data: [missingTarget, target2, target], // in this mode the content of the first existing file is returned
      pipeline: 'file>json'
    }
  }
}, {
  mode: 'sync',
  pipeline: 'datatree'
})

config.get('someParam') // "bar2"

Keywords

universal config

FAQs

Package last updated on 18 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts