question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No files are written: mkdir@1.0.0 broke mkdir-promise as such writeFile processor broke

See original GitHub issue

mkdirp@1.0.0 changed implementation from callback to promisified api


mkdir-promise has "mkdirp": "*" dependency: https://github.com/ahmadnassri/mkdirp-promise/blob/master/package.json#L37


As such, the writeFile stopped working because the Promise never resolves.

https://github.com/angular/dgeni-packages/blob/master/base/services/writeFile.js#L1


I fixed it locally in a project workspace by overriding the factory with a custom implementation:

import * as mkdirp from 'mkdirp';
import * as fs from 'fs';
import * as path from 'canonical-path';

/**
 * mkdirp module changed implementation from callback to promise in 1.0.0
 *
 * As such, mkdir-promise stopped working.
 *
 * @link https://github.com/isaacs/node-mkdirp/blob/master/CHANGELOG.md
 */
export default function writeFile() {

  return function(file, content) {

    return new Promise((resolve, reject) => {
        mkdirp(path.dirname(file), undefined, (err, made) => {
          if (err === null) {
            resolve(made);
          } else {
            reject(err);
          }
        });
      }).then(() => new Promise((resolve, reject) => {
        fs.writeFile(file, content, function (err) {
          if (err) {
            reject(err);
          }
          resolve();
        });
      }));
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
petebacondarwincommented, Feb 12, 2020

Thanks for raising this @dherges - it must have been quite a pain to debug what was going on!

1reaction
petebacondarwincommented, Feb 12, 2020

I just got hit by this when updating AIO 🙀 So I better get on and fix it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - How to write file if parent folder doesn't exist?
Almost the same as writeFile (i.e. it overwrites), except that if the parent directory does not exist, it's created. options are what you'd...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found