Allow HMR as a dependency access phantomjs

Author: clintandrewhallCreated Aug 24, 2018Updated Dec 18, 2019

I'm using HackMyResume as a dependency in my own website, building the output as my site is deployed. Since it's Heroku, I can't guarantee wkthmltopdf, phantomjs, etc are installed.

I can use phantomjs-prebuilt, so I edited html-pdf-cli-generator to check if phantomjs-prebuilt was installed, and used it instead:

    let pathToBin = 'phantomjs';

    // If the executable was installed in the node_modules directory of a
    // project, and that project includes wkhtmltopdf, use that instance
    // instead.
    try {
      const installed = detectInstalled.sync('phantomjs-prebuilt', {
        cwd: process.cwd(),
        local: true,
      });
      if (installed) {
        pathToBin = PATH.join(process.cwd(), 'node_modules', '.bin', 'phantomjs');
      }
    } catch (e) {
      return false;
    }

    SPAWN(pathToBin, [ scriptPath, sourcePath, destPath ], false, on_error, this);

Any thoughts on this approach, before I submit a PR?