XervoIO / demeteorizer

Converts a Meteor app into a standard Node.js application.
http://npm.im/demeteorizer
MIT License
703 stars 59 forks source link

Removing process.chdir #253

Closed HZSamir closed 7 years ago

HZSamir commented 7 years ago

Hello, Not exactly an issue but I wonder if it would be possible to demeteorize my Meteor app without resorting to process.chdir(require('path').join(__dirname, 'programs', 'server')); Something like rewring all the paths to match their location.

The reason being that I'm trying to bundle it inside an ASAR file, which does not play well with Chdir.

Is it at all possible? Thank you.

HZSamir commented 7 years ago

Please disregard this issue. I have managed to solve it by monkey-patching the chdir method like so:

const path = require('path');

let cwd = '';

process.chdir = (newPath) => {
  cwd = newPath;
};

const originalReadFileSync = require('fs').readFileSync;

require('fs').readFileSync = (filePath, ...args) => {
  let newPath = filePath;
  return originalReadFileSync(newPath, ...args);
};