Skip to content

Commit

Permalink
Allow calling bin/hatch-previewer from other directories
Browse files Browse the repository at this point in the history
Now non-flatpak standalone requires bin/hatch-previewer to be run from
the root of the repository.

Change path to the module to be the module path, not the current
directory, in the case where we are not in a flatpak package and not
imported as a module.

Otherwise if `PATH/TO/bin/hatch-previewer <path>` is called from an
ingester dir, the `index.js` of the ingester is executed!
  • Loading branch information
manuq committed Mar 1, 2018
1 parent b1d9231 commit fe67017
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bin/hatch-previewer
Expand Up @@ -16,11 +16,11 @@ const allArgs = process.argv;
const passedArgs = allArgs.slice(2);

// Try to load us as a module if we're imported, otherwise if /app/main exists,
// assume we're running in a flatpak package. Lastly, run from the current
// assume we're running in a flatpak package. Lastly, run from the parent
// directory.
let pathToHatchPreviewerModule = '/app/main';
if (!fs.existsSync(pathToHatchPreviewerModule))
pathToHatchPreviewerModule = path.resolve('.');
pathToHatchPreviewerModule = path.resolve(__dirname, '..');
try {
pathToHatchPreviewerModule = path.dirname(require.resolve('hatch-previewer'));
} catch (e) {
Expand Down

0 comments on commit fe67017

Please sign in to comment.