diff --git a/lib/generator.js b/lib/generator.js index 0bf09456ce..1ac8f22b9b 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -33,7 +33,7 @@ const { const { parse, usesNewAPI, getProperApiDocument } = require('./parser'); const { registerFilters } = require('./filtersRegistry'); const { registerHooks } = require('./hooksRegistry'); -const { definitions, flatten, shorthands } = require('@npmcli/config/lib/definitions') +const { definitions, flatten, shorthands } = require('@npmcli/config/lib/definitions'); const FILTERS_DIRNAME = 'filters'; const HOOKS_DIRNAME = 'hooks'; @@ -550,7 +550,6 @@ class Generator { log.debug(`Using npm registry ${registryUrl} and authorization type ${authorizationName} to handle template installation.`); } - /** * Downloads and installs a template and its dependencies * @@ -591,13 +590,13 @@ class Generator { flatten, shorthands, npmPath - }) + }); - await config.load() + await config.load(); const arbOptions = {...{path: ROOT_DIR}, ...config.flat}; - if (!(Object.keys(this.registry).length === 0)) { + if (Object.keys(this.registry).length !== 0) { this.initialiseArbOptions(arbOptions); } const arb = new Arborist(arbOptions); diff --git a/test/__mocks__/@npmcli/config.js b/test/__mocks__/@npmcli/config.js deleted file mode 100644 index c0cae96c8d..0000000000 --- a/test/__mocks__/@npmcli/config.js +++ /dev/null @@ -1,9 +0,0 @@ -const config = jest.genMockFromModule('@npmcli/config'); - -config.prototype[Symbol.for('resolvedAdd')] = [{name: 'test'}]; - -config.prototype.load = jest.fn(async (opt) => { - return; -}); - -module.exports = config; \ No newline at end of file diff --git a/test/generator.test.js b/test/generator.test.js index fdd58ddaa9..52d45a8e1d 100644 --- a/test/generator.test.js +++ b/test/generator.test.js @@ -333,15 +333,11 @@ describe('Generator', () => { describe('#installTemplate', () => { let ArboristMock; let arboristMock; - let ConfigMock; - let configMock; let utils; beforeEach(() => { ArboristMock = require('@npmcli/arborist'); arboristMock = new ArboristMock(); - ConfigMock = require('@npmcli/arborist'); - configMock = new ConfigMock(); utils = require('../lib/utils'); jest.mock(path.resolve('./testTemplate', 'package.json'), () => ({ name: 'nameOfTestTemplate' }), { virtual: true }); jest.mock(path.resolve(Generator.DEFAULT_TEMPLATES_DIR, 'nameOfTestTemplate', 'package.json'), () => ({ name: 'nameOfTestTemplate' }), { virtual: true }); @@ -432,7 +428,7 @@ describe('Generator', () => { const t = () => new Generator('testTemplate', __dirname, { url: 'some.url.com', privateKey: 'some.key' - + }); expect(t).toThrow('These options are not supported by the generator: privateKey'); });