GithubHelp home page GithubHelp logo

exec-buffer's Introduction

exec-buffer Build Status

Run a Buffer through a child process

Install

$ npm install exec-buffer

Usage

const fs = require('fs');
const execBuffer = require('exec-buffer');
const gifsicle = require('gifsicle').path;

execBuffer({
	input: fs.readFileSync('test.gif'),
	bin: gifsicle,
	args: ['-o', execBuffer.output, execBuffer.input]
}).then(data => {
	console.log(data);
	//=> <Buffer 47 49 46 38 37 61 ...>
});

API

execBuffer(options)

options

Type: Object

input

Type: Buffer

The Buffer to be ran through the child process.

bin

Type: string

Path to the binary.

args

Type: Array

Arguments to run the binary with.

inputPath

Type: string
Default: tempfile()

Where input will be written to. In most cases you don't need to set this.

outputPath

Type: string
Default: tempfile()

Where output file will be written to. In most cases you don't need to set this.

execBuffer.input

Returns a temporary path to where the input file will be written.

execBuffer.output

Returns a temporary path to where the output file will be written.

License

MIT © Kevin Mårtensson

exec-buffer's People

Contributors

graingert avatar kevva avatar shinnn avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exec-buffer's Issues

please update depencencies avoid error on build

I try to use imagemin and imagemin-webp on wepback project.
And then still trying to do something good, i get error about dependency exec-buffer. It's give me an error:

This dependency was not found:

* child_process in ./node_modules/exec-buffer/node_modules/cross-spawn/index.js, ./node_modules/exec-buffer/node_modules/execa/index.js 
and 1 other

Try to manage it my self but at the end it seems to be a dependencies error of depends packages of imagemin....

node v12.16.1
npm v6.14.4
yarn v1.22.4
windows 10

stderr output does not imply failure

this module, when used by imagemin-pngcrush, causes issues when pngcrush outputs warnings to stderr.

This module should be assuming success if the command finishes with a zero exit status. stderr is often used for debug, warning, or logging purposes when stdout can be used as the output of a process.

I can write a test and PR if this is something that will be merged quickly.

Concatenating file names with parameters

@kevva Nice library, thank you.

Trying to run jpegmini with it. The syntax I need:

jpegmini -f=input_file -o=outputfile

I tried:

  • ['-f', execBuffer.input, '-o', execBuffer.output]
  • ['-f=', execBuffer.input, '-o=', execBuffer.output]
  • ['-f="', execBuffer.input, '" -o="', execBuffer.output, '"']
  • ['"-f=', execBuffer.input, '" "-o=', execBuffer.output, '"']

None of the above works with jpegmini.

Given that execBuffer.input and execBuffer.output are Symbols, I can't just use args: ['-f=' + execBuffer.input, '-o=' + execBuffer.output]

How about adding execBuffer.inputFile() and execBuffer.outputFile() that would return strings (e.g. using random uuid) that would later be replaced with actual filenames in all parameters?

Or maybe you have some better idea how to address it... I can do PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.