From 1ff2e040b5491f1ec8a6067e622f0480fa9d991a Mon Sep 17 00:00:00 2001 From: Ben Surgison Date: Mon, 16 May 2022 16:07:42 +0100 Subject: [PATCH] Remove gulp from unit tests --- __tests__/spec/sanity-checks.js | 5 +++++ package.json | 2 +- run-tasks.js | 19 +++++++++++++++---- start.js | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/__tests__/spec/sanity-checks.js b/__tests__/spec/sanity-checks.js index e00c0dbe16..0e29ee46a4 100644 --- a/__tests__/spec/sanity-checks.js +++ b/__tests__/spec/sanity-checks.js @@ -11,6 +11,7 @@ const sass = require('sass') const app = require('../../server.js') const gulpConfig = require('../../gulp/config.json') const utils = require('../../lib/utils') +const { generateAssets } = require('../../run-tasks') function readFile (pathFromRoot) { return fs.readFileSync(path.join(__dirname, '../../' + pathFromRoot), 'utf8') @@ -20,6 +21,10 @@ function readFile (pathFromRoot) { * Basic sanity checks on the dev server */ describe('The Prototype Kit', () => { + beforeAll(() => { + generateAssets() + }) + it('should generate assets into the /public folder', () => { assert.doesNotThrow(function () { fs.accessSync(path.resolve(__dirname, '../../public/javascripts/application.js')) diff --git a/package.json b/package.json index 7b6af76f84..ebe4a2a106 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "test:integration:edge": "start-server-and-test 3000 'cypress run --browser edge'", "test:integration:chrome": "start-server-and-test 3000 'cypress run --browser chrome'", "test:integration:electron": "start-server-and-test 3000 'cypress run --browser electron'", - "test": "gulp generate-assets && jest && npm run lint" + "test": "jest && npm run lint" }, "dependencies": { "acorn": "^8.5.0", diff --git a/run-tasks.js b/run-tasks.js index dafd552be5..bed2a488a9 100644 --- a/run-tasks.js +++ b/run-tasks.js @@ -1,5 +1,6 @@ const colour = require('nodemon/lib/utils/colour') -module.exports = function () { + +function runTasks () { clean() sassExtensions() // in parallel: @@ -10,6 +11,13 @@ module.exports = function () { runNodemon() } +function generateAssets () { + clean() + sassExtensions() + sass() + copyAssets() +} + function clean () { // doesn't clean extensions.scss, should it? const fs = require('fs') @@ -69,9 +77,7 @@ function copyAssets () { // shouldnt have to mkdir, but copy errors with EEXIST otherwise fs.mkdirSync('public', { recursive: true }) - fs.copy('app/assets', 'public', { filter: filterFunc }, err => { - if (err) return console.error(err) - }) + fs.copySync('app/assets', 'public', { filter: filterFunc }) } function watch () { @@ -129,3 +135,8 @@ function runNodemon () { .on('crash', onCrash) .on('quit', onQuit) } + +module.exports = { + runTasks, + generateAssets +} diff --git a/start.js b/start.js index 20e3ce8163..c72ea42711 100644 --- a/start.js +++ b/start.js @@ -3,7 +3,7 @@ const path = require('path') const fs = require('fs') // Local dependencies -const runTasks = require('./run-tasks') +const { runTasks } = require('./run-tasks') checkFiles()