- Version: v9.3.0
- Platform: macOS 10.13.1 High Sierra
I'm facing a problem when I have many fs promisifyed functions in one file, specifically promisifyed fs.truncate and fs.open in one file
This work fine, result undefined as expected
const fs = require('fs');
const path = require('path');
const { promisify } = require('util');
fs.truncate = promisify(fs.truncate);
fs.truncate(path.resolve(__dirname, '../.logs/123.log'))
.then(console.log)
.catch(console.error);
fs.open = promisify(fs.open);
But if I put fs.open = promisify(fs.open) above invoking fs.truncate, my promise do not resolve or reject
fs.truncate = promisify(fs.truncate);
fs.open = promisify(fs.open);
fs.truncate(path.resolve(__dirname, '../.logs/123.log'))
.then(console.log)
.catch(console.error);