GithubHelp home page GithubHelp logo

mz's People

Contributors

dead-horse avatar dvlsg avatar fmpenz avatar greenkeeperio-bot avatar h2non avatar jiangjie avatar jonathanong avatar jongleberry-bot avatar linusu avatar markherhold avatar mikailbag avatar petkaantonov avatar rstacruz avatar ryanzim avatar tracker1 avatar wmertens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mz's Issues

exec('mv file1 file2') appears to be defective

exec appears to work differently for move operations (linux mv command). I am not sure whether this is a bug or whether mv is a special case. Please take a look at the two code snippets below. The first code block works as expected, but the second code block does not.

The code below works as expected, i.e. the promise resolves after the move operation finishes

const exec = require('child_process').exec;
//inside some function:
   return new Promise((resolve, reject) => {
        exec('mv file1 file2', (err, out) => {
          if (err)
            reject(err);
          else
            resolve(out);
        })
      });

The code below resolves before mv finishes.

const exec = require('mz/child_process').exec;
//inside some function:
    return exec('mv file1 file2')

Use fs.promises where possible

Node now ships with an fs promise API, it would be cool if mz would detect if that API is available (optionally?) and use it if it's there.

fs.truncate missing

It appears fs.truncate is missing from the list of fs modules to wrap -- is this intentional? I can confirm that adding 'truncate' to the api array allows me to use it as intended.

Not a huge deal, though, I can just use ftruncate.

Typescript binding

Hi,

I love the idea of mz. I mainly use Typescript. Do you known if anyone has started writing a Type Definition for mz ?

I am OK to make one, but I'd rather not redo something existing and currently under work.

Olivier

If `completer` rejects, callback is called twice

I was just browsing through the code and came across this:

    result.catch(cb).then(function (result) {
      process.nextTick(function () { cb(null, result) })
    }

So, if result rejects, we'll .catch(cb) and call the callback, but then .then(function(result) {... will be called with whatever cb returns, so we'll call cb again next tick. This should be:

    result.then(
      function (result) {
        process.nextTick(function () { cb(null, result) })
      },
      cb
    );

(Edit to add link to code)

pls stop

why is it a good idea to enable "developers" to continue to use software that is long past is lifespan, and probably a giant security threat?

Bluebird Promises !~= ES6 Promises

I was just curious about the decision to use Bluebird Promises in the absence of ES6 Promises. I know this topic has been discussed ad nauseam in other threads, and there are a lot of reasons to think Bluebird Promises are better... but, it does seem like this sets up future pain when switching from Bluebird to native, as I assume many code bases will at some point.

My suggested alternative would be to use a Promise shim that stays spec-compliant.

Why not bluebird promisify?

Hey! Love the repo! Was wondering why this commit 238998b says not to use bluebird.promisify(), and what's going on with all this eval business, very curious! Thanks!

mkdtemp

Currently there is no support for mkdtemp (added in node 5.0.0).

Unable to access process output and error streams on error

The promise interface does not allow recovering stderr/stdout from child_process.exec and similar functions, although the callback interface does expose them, in case of error (in particular when the command has a non-zero exit state)

Different output with mz/child_process.exec vs node's child_process.exec

When I use exec I am getting different output with mz/child_process than child_process. Example program outputting git tags:

const cp = require('child_process');
const mzcp = require('mz/child_process');


function execPromise(cmd) {
  return new Promise((resolve, reject) => {
    cp.exec(cmd, (err, stdout) => {
      err ? reject(err) : resolve(stdout);
    });
  })
}

async function test(name, exec) {
  console.log('TESTING: ', name, '\n');
  const stdout = await exec('git tag --sort version:refname');
  console.log(stdout.toString('utf8'));
  console.log('END TEST: ', name, '\n\n');
}

async function main() {
  await test('node', execPromise);
  await test('mz', mzcp.exec);
}

main();

child_process output

TESTING:  node

v0.1.0
v0.2.1
v0.2.2
v0.2.3
v0.3.0
v0.4.0
v0.4.1
v0.5.0
v0.6.0

END TEST:  node

mz/child_process output

TESTING:  mz

[ 'v0.1.0\nv0.2.1\nv0.2.2\nv0.2.3\nv0.3.0\nv0.4.0\nv0.4.1\nv0.5.0\nv0.6.0\n',
  '' ]
END TEST:  mz

Running git tag --sort version:refname in terminal

bash-3.2$ git tag --sort version:refname
v0.1.0
v0.2.1
v0.2.2
v0.2.3
v0.3.0
v0.4.0
v0.4.1
v0.5.0
v0.6.0

Environment
node: v7.8.0
os: 10.12.4

Use es5-shim and es6-shim

There are many ways that all versions of v8 (all JS engines, in fact) deviate from the spec.

By using the es5-shim and es6-shim, you'll ensure that all ES5 and ES6 APIs are spec-compliant and consistent.

I would not recommend using bluebird, because it adds additional methods that are not part of the spec, and it also does not support subclassing in a spec-compliant way. (I'd also recommend object.assign over object-assign since it's more spec-compliant, if you end up not wanting the es6-shim)

fs.stat() fully blocking with await, forever

This is my code:

const fs = require('mz/fs');
const modules = []
client.on("ready", async () => {
  console.log("Logged in to discord!");
  client.user.setGame("!help")

  // start loading modules
  const files = await fs.readdir("./modules").catch(e => {
    console.error("Module directory could not be found, aborting", argv.debug ? `\n${error}` : "")
    process.exit( 1 )
  })
  for(const file of files) {
    // Make one pass and make the file complete
    const stat = await fs.stat(`./modules/${file}`).catch(e => {
      console.error("Error stating file.", argv.debug ? `\n${e}` : "")
    })

    if(stat.isDirectory()) {
      return
    }

    debug(`Loaded ./modules/${file}`)
    const mod = require(`./modules/${file}`)
    mod.init(client)
    modules.push(mod)
  };
  console.log(`Bot started successfully, ${modules.length} modules loaded`)
});

it never gets to even print the last console.log, no matter how long I leave it to run

Errors are missing stack traces

Hi,

Stack trace is missing even for non fs related errors when mz/fs is used in promise chain:

const fs = require('mz/fs');
let a;

fs.readdir('.')
  .then(files => a.invalid)
  .catch(console.log);

TypeError: Cannot read property 'invalid' of undefined at fs.readdir.then.files (/Users/ozum/Development/l10n-formatjs/sil.js:10:19)

On the other hand Bluebird or fs-extra-promise has stacks:

const Promise = require('bluebird')
const fs      = Promise.promisifyAll(require('fs-extra'));
// OR const fs   = require('fs-extra-promise');

let a;

fs.readdirAsync('.')
  .then(files => a.invalid)
  .catch(console.log);
TypeError: Cannot read property 'invalid' of undefined
    at fs.readdirAsync.then.files (/Users/ozum/Development/l10n-formatjs/sil.js:9:19)
    at tryCatcher (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/promise.js:638:18)
    at /Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/nodeback.js:42:21
    at go$readdir$cb (/Users/ozum/Development/l10n-formatjs/node_modules/fs-extra-promise/node_modules/graceful-fs/graceful-fs.js:149:14)
    at FSReqWrap.oncomplete (fs.js:114:15)

How to use with single exported functions

I found this library and I think it's brilliant. but I have some issues with a library that is just a function rimraf

const rimraf = require('mz/rimraf')
...
Error: Cannot find module 'mz/rimraf'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)

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.