Skip to content

Commit

Permalink
Use Gulp path options where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Dec 12, 2023
1 parent 4c13a8a commit 7bcb23a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
9 changes: 5 additions & 4 deletions tasks/assets.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { join } from 'path'

import { task } from '@govuk-frontend/tasks'
import gulp from 'gulp'

Expand All @@ -12,7 +10,10 @@ export const assets = (options) =>
gulp.series(
task.name('copy:assets', () =>
gulp
.src(join(options.srcPath, 'govuk/assets/**/*'))
.pipe(gulp.dest(join(options.destPath, 'govuk/assets')))
.src('govuk/assets/**/*', {
base: options.srcPath,
cwd: options.srcPath
})
.pipe(gulp.dest(options.destPath))
)
)
9 changes: 5 additions & 4 deletions tasks/build/package.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { join } from 'path'

import { paths } from '@govuk-frontend/config'
import { npm, task } from '@govuk-frontend/tasks'
import gulp from 'gulp'
Expand All @@ -26,7 +24,10 @@ export default (options) =>
// Copy GOV.UK Prototype Kit JavaScript
task.name("copy:files 'govuk-prototype-kit'", () =>
gulp
.src(join(options.srcPath, 'govuk-prototype-kit/**/*.js'))
.pipe(gulp.dest(join(options.destPath, 'govuk-prototype-kit')))
.src('govuk-prototype-kit/**/*.js', {
base: options.srcPath,
cwd: options.srcPath
})
.pipe(gulp.dest(options.destPath))
)
)
7 changes: 5 additions & 2 deletions tasks/build/release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export default (options) =>
// Copy GOV.UK Frontend static assets
task.name('copy:assets', () =>
gulp
.src(join(options.srcPath, 'govuk/assets/**/*'))
.pipe(gulp.dest(join(options.destPath, 'assets')))
.src('govuk/assets/**/*', {
base: join(options.srcPath, 'govuk'),
cwd: options.srcPath
})
.pipe(gulp.dest(options.destPath))
),

// Compile GOV.UK Frontend JavaScript
Expand Down
7 changes: 4 additions & 3 deletions tasks/templates.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { join } from 'path'

import { task } from '@govuk-frontend/tasks'
import gulp from 'gulp'

Expand All @@ -12,7 +10,10 @@ export const templates = (options) =>
gulp.series(
task.name('copy:templates', () =>
gulp
.src(join(options.srcPath, 'govuk/**/*.{md,njk}'))
.src('govuk/**/*.{md,njk}', {
base: options.srcPath,
cwd: options.srcPath
})
.pipe(gulp.dest(options.destPath))
)
)
21 changes: 12 additions & 9 deletions tasks/watch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const watch = (options) =>
*/
task.name('lint:scss watch', () =>
gulp.watch(
[join(options.srcPath, '**/*.scss')],
'**/*.scss',
{ cwd: options.srcPath },

// Run Stylelint checks
npm.script('lint:scss:cli', [
Expand All @@ -37,16 +38,16 @@ export const watch = (options) =>
* Stylesheets build watcher
*/
task.name('compile:scss watch', () =>
gulp.watch([join(options.srcPath, '**/*.scss')], styles(options))
gulp.watch('**/*.scss', { cwd: options.srcPath }, styles(options))
),

/**
* JavaScripts lint watcher
*/
task.name('lint:js watch', () =>
gulp.watch(
join(options.srcPath, '**/*.{cjs,js,mjs}'),
{ ignored: ['**/*.test.*'] },
'**/*.{cjs,js,mjs}',
{ cwd: options.srcPath, ignored: ['**/*.test.*'] },
gulp.parallel(
// Run TypeScript compiler
npm.script('build:types', ['--incremental', '--pretty'], options),
Expand All @@ -64,8 +65,8 @@ export const watch = (options) =>
*/
task.name('compile:js watch', () =>
gulp.watch(
join(options.srcPath, '**/*.{cjs,js,mjs}'),
{ ignored: ['**/*.test.*'] },
'**/*.{cjs,js,mjs}',
{ cwd: options.srcPath, ignored: ['**/*.test.*'] },
scripts(options)
)
),
Expand All @@ -75,7 +76,8 @@ export const watch = (options) =>
*/
task.name('compile:fixtures watch', () =>
gulp.watch(
[join(options.srcPath, 'govuk/components/*/*.yaml')],
'govuk/components/*/*.yaml',
{ cwd: options.srcPath },
fixtures(options)
)
),
Expand All @@ -85,13 +87,14 @@ export const watch = (options) =>
*/
task.name('copy:templates watch', () =>
gulp.watch(
[join(options.srcPath, 'govuk/**/*.{md,njk}')],
'govuk/**/*.{md,njk}',
{ cwd: options.srcPath },
templates(options)
)
),

// Copy GOV.UK Frontend static assets
task.name('copy:assets watch', () =>
gulp.watch([join(options.srcPath, 'govuk/assets/**')], assets(options))
gulp.watch('govuk/assets/**', { cwd: options.srcPath }, assets(options))
)
)

0 comments on commit 7bcb23a

Please sign in to comment.