From cb2624bdb9f15defc0b9231b748ab9fe7a2159de Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Mon, 26 Jun 2023 11:12:31 +0100 Subject: [PATCH] Revert "Revert "Migrate task arguments helper to CommonJS"" This reverts commit d44da27de9118657efd5f5aac8470f2eab47fc25. --- packages/govuk-frontend/postcss.config.mjs | 2 +- .../helpers/{task-arguments.mjs => task-arguments.js} | 4 ++-- ...ments.unit.test.mjs => task-arguments.unit.test.js} | 10 +++++----- shared/tasks/npm.mjs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename shared/tasks/helpers/{task-arguments.mjs => task-arguments.js} (55%) rename shared/tasks/helpers/{task-arguments.unit.test.mjs => task-arguments.unit.test.js} (80%) diff --git a/packages/govuk-frontend/postcss.config.mjs b/packages/govuk-frontend/postcss.config.mjs index f725e8b4a8..d4e3ee2f8a 100644 --- a/packages/govuk-frontend/postcss.config.mjs +++ b/packages/govuk-frontend/postcss.config.mjs @@ -2,7 +2,7 @@ import autoprefixer from 'autoprefixer' import cssnano from 'cssnano' import cssnanoPresetDefault from 'cssnano-preset-default' import { pkg } from 'govuk-frontend-config' -import { isDev } from 'govuk-frontend-tasks/helpers/task-arguments.mjs' +import { isDev } from 'govuk-frontend-tasks/helpers/task-arguments.js' import postcss from 'postcss' import scss from 'postcss-scss' diff --git a/shared/tasks/helpers/task-arguments.mjs b/shared/tasks/helpers/task-arguments.js similarity index 55% rename from shared/tasks/helpers/task-arguments.mjs rename to shared/tasks/helpers/task-arguments.js index 420537dd8e..75333012ff 100644 --- a/shared/tasks/helpers/task-arguments.mjs +++ b/shared/tasks/helpers/task-arguments.js @@ -1,7 +1,7 @@ -import parser from 'yargs-parser' +const parser = require('yargs-parser') // Non-flag arguments as tasks const { _: tasks } = parser(process.argv) // Check for development task -export const isDev = tasks.includes('dev') +module.exports.isDev = tasks.includes('dev') diff --git a/shared/tasks/helpers/task-arguments.unit.test.mjs b/shared/tasks/helpers/task-arguments.unit.test.js similarity index 80% rename from shared/tasks/helpers/task-arguments.unit.test.mjs rename to shared/tasks/helpers/task-arguments.unit.test.js index 17e57e2b61..043e4a66a6 100644 --- a/shared/tasks/helpers/task-arguments.unit.test.mjs +++ b/shared/tasks/helpers/task-arguments.unit.test.js @@ -26,35 +26,35 @@ describe('Task arguments', () => { it('is flagged false', async () => { process.argv = [...argv] - const { isDev } = await import('./task-arguments.mjs') + const { isDev } = require('./task-arguments.js') expect(isDev).toBe(false) }) it("is flagged false for 'gulp build:app'", async () => { process.argv = [...argv, 'build:app'] - const { isDev } = await import('./task-arguments.mjs') + const { isDev } = require('./task-arguments.js') expect(isDev).toBe(false) }) it("is flagged false for 'gulp build:package'", async () => { process.argv = [...argv, 'build:package'] - const { isDev } = await import('./task-arguments.mjs') + const { isDev } = require('./task-arguments.js') expect(isDev).toBe(false) }) it("is flagged false for 'gulp build:release'", async () => { process.argv = [...argv, 'build:release'] - const { isDev } = await import('./task-arguments.mjs') + const { isDev } = require('./task-arguments.js') expect(isDev).toBe(false) }) it("is flagged true for 'gulp dev'", async () => { process.argv = [...argv, 'dev'] - const { isDev } = await import('./task-arguments.mjs') + const { isDev } = require('./task-arguments.js') expect(isDev).toBe(true) }) }) diff --git a/shared/tasks/npm.mjs b/shared/tasks/npm.mjs index 5bec8c9b94..90d1c39d63 100644 --- a/shared/tasks/npm.mjs +++ b/shared/tasks/npm.mjs @@ -2,7 +2,7 @@ import runScript from '@npmcli/run-script' import { paths } from 'govuk-frontend-config' import PluginError from 'plugin-error' -import { isDev } from './helpers/task-arguments.mjs' +import { isDev } from './helpers/task-arguments.js' import { task } from './index.mjs' /**