Socket
Socket
Sign inDemoInstall

afix

Package Overview
Dependencies
5
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    afix

Tiny fixture utility.


Version published
Weekly downloads
10
increased by233.33%
Maintainers
1
Install size
56.1 kB
Created
Weekly downloads
 

Readme

Source

afix

npm version test coverage npm bundle size

Tiny fixture utility.

npm i afix

Usage

Each call to afix() creates a new directory in process.cwd() and writes files within the new directory.

import fs from 'fs'
import { afix } from 'afix'

const fixture = afix({
  config: ['config.js', 'export default { foo: true }'],
  nested: ['some/path/file.js'],
})
const dir = fixture.mkdir('/some/dir')

fs.existsSync(fixture.root) // true

fs.existsSync(fixture.files.config.path) // true
assert.equal(fs.readFileSync(fixture.files.config.path, 'utf8'), fixture.files.config.content)

fs.existsSync(fixture.files.nested.path) // true
assert.equal(fs.readFileSync(fixture.files.nested.path, 'utf8'), fixture.files.nested.content)

fs.existsSync(dir) // true

// remove fixture.root
fixture.cleanup()

fs.existsSync(fixture.root) // false

Plus, fixtures are automaticaly removed when the process exits.

License

MIT License © Sure Thing

FAQs

Last updated on 06 Jan 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc