Socket
Socket
Sign inDemoInstall

handmade-fs

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    handmade-fs

File system tasks for handmade.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
69.5 kB
Created
Weekly downloads
 

Readme

Source

handmade-fs

handmade-fs on NPM handmade-fs on Travis Standard JavaScript Style handmade-fs Stability Index

File system tasks for handmade.

Install

# via npm
$ npm i handmade-fs --save

# via yarn
$ yarn add handmade-fs

Use

handmade-fs exports read and write tasks.

const {
  read,
  write
} = require('handmade-fs')

.read(path)

Accepts a path to an existing folder, relative to the root of the build.

Reads contents of all files within, populating the build object with the file data.

const handmade = require('handmade')
const { read } = require('handmade-fs')

// read path is relative to this context
handmade(__dirname)
  // relative path to source files
  .task(read('./src'))

  // in subsequent tasks, access the read path and file data from the core
  .task(contents => new Promise((resolve, reject) => {    
    const {
      files,
      read
    } = contents.core

    resolve(contents)
  }))

  // start the build
  .build()

.write(path)

Accepts a path to a new or existing folder, relative to the root of the build.

Creates necessary folders and writes files, using the file data from the build object.

const handmade = require('handmade')

const {
  read,
  write
} = require('handmade-fs')

// write path is relative to this context
handmade(__dirname)
  // relative path to src files
  .task(read('./src'))

  // relative path to dist files
  .task(write('./dist'))

  // start the build
  .build()

Because the file data isn't modified in a different task between the read and write tasks, the above code essentially copies the src folder contents to the dist folder.

Roadmap

  • Add merge option (read multiple folders into same object)

License

MIT. © 2017 Michael Cavalea

FAQs

Last updated on 01 Mar 2017

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