Skip to content

Commit

Permalink
bin/repl: handle missing should dependency
Browse files Browse the repository at this point in the history
Dev dependencies are not available in production environments.

Closes getodk#1227
  • Loading branch information
alxndrsn committed Oct 16, 2024
1 parent 4330775 commit b9d6863
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/bin/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
// including this file, may be copied, modified, propagated, or distributed
// except according to the terms contained in the LICENSE file.

const should = require('should'); // eslint-disable-line import/no-extraneous-dependencies
require('../../test/assertions');

const _ = require('lodash'); // eslint-disable-line import/no-extraneous-dependencies
const { sql } = require('slonik');

const container = require('../util/default-container');

(async () => {
const context = { ..._.omit(container, 'with'), container, should, sql };
const contextKeys = Object.keys(context).sort();
console.log('Available vars:', contextKeys.join(', '));
const context = { ..._.omit(container, 'with'), container, sql };
const contextKeys = Object.keys(context);

try {
context.should = require('should'); // eslint-disable-line import/no-extraneous-dependencies
contextKeys.push('should'); // manually add due to should.js prototype pollution
require('../../test/assertions');
} catch(err) { /* skip devDependencies if unavailable */ }

Check failure on line 23 in lib/bin/repl.js

View workflow job for this annotation

GitHub Actions / standard-tests

Expected space(s) after "catch"

console.log('Available vars:', contextKeys.sort().join(', '));

const repl = require('repl').start({
useGlobal: true, // enable should.js prototype pollution
Expand Down

0 comments on commit b9d6863

Please sign in to comment.