Skip to content

Commit

Permalink
Revert "Revert "Migrate task arguments helper to CommonJS""
Browse files Browse the repository at this point in the history
This reverts commit d44da27.
  • Loading branch information
colinrotherham committed Jun 26, 2023
1 parent 11ec0f1 commit cb2624b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/govuk-frontend/postcss.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
@@ -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')
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
Expand Down
2 changes: 1 addition & 1 deletion shared/tasks/npm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'

/**
Expand Down

0 comments on commit cb2624b

Please sign in to comment.