Skip to content

Commit

Permalink
pass moduleName to webpackConfigStandalone via process 'global'
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnC-80 committed Nov 13, 2024
1 parent c619fd6 commit 2cc84d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion lib/commands/test/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const StripesCore = importLazy('../../cli/stripes-core');

function cypressCommand(argv) {
const context = argv.context;

// pass moduleName up to globals so that it can be accessed for standalone webpack config.
process.env.stripesCLIContextModuleName = context.moduleName;

// Default test command to test env
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'test';
Expand Down Expand Up @@ -51,7 +55,7 @@ function cypressCommand(argv) {
webpackConfig.mode = 'none';

const cypressService = new CypressService(context.cwd);
cypressService.runCypressTests(webpackConfig, Object.assign({}, argv.cypress, { watch: argv.watch, cache: argv.cache }));
cypressService.runCypressTests(webpackConfig, Object.assign({}, argv.cypress, { watch: argv.watch, cache: argv.cache }), context);
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion lib/test/cypress-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getTestIndex(cwd, dirs) {
return file;
}

function getBaseCypressConfig(fn = (cfg) => cfg) {
function getBaseCypressConfig(fn = (cfg) => cfg, context) {

Check warning on line 22 in lib/test/cypress-service.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

'context' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 22 in lib/test/cypress-service.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

'context' is defined but never used. Allowed unused args must match /^_/u
const baseConfig = defineConfig({
browser: 'chrome',
viewportWidth: 800,
Expand Down
12 changes: 8 additions & 4 deletions lib/test/webpack-config-standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ const getStripesWebpackConfig = require('./webpack-config');
const StripesCore = require('../cli/stripes-core');

module.exports = function getStripesWebpackConfigStandalone() {
const cwd = process.cwd();
const cliRoot = path.resolve('@folio/stripes-cli');
const stripesCore = new StripesCore({ cwd, cliRoot }, { '@folio/stripes-webpack': '@folio/stripes-webpack' });
const context = {
moduleName: process.env.stripesCLIContextModuleName || '',
cwd: process.cwd(),
cliRoot: path.resolve('@folio/stripes-cli')
};

const stripesCore = new StripesCore(context, { '@folio/stripes-webpack': '@folio/stripes-webpack' });

const componentsStripesConfig = { config: [], modules:[], languages: [] };
const webpackConfig = getStripesWebpackConfig(stripesCore, componentsStripesConfig, { config: componentsStripesConfig }, {});
const webpackConfig = getStripesWebpackConfig(stripesCore, componentsStripesConfig, { config: componentsStripesConfig }, context);
return webpackConfig;
};

0 comments on commit 2cc84d9

Please sign in to comment.