summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2021-04-08 12:41:57 +0200
committerGitHub <noreply@github.com>2021-04-08 12:41:57 +0200
commit0d1a5e0ffcf689e6e6b2aaa4a4251db74f6b487b (patch)
treec9c854a4efc5c623743ef09fdb3cd37215c4549b /build
parent4eea819b2496b849ca8e1e7a6e11fef45e141225 (diff)
downloadgitea-0d1a5e0ffcf689e6e6b2aaa4a4251db74f6b487b.tar.gz
gitea-0d1a5e0ffcf689e6e6b2aaa4a4251db74f6b487b.zip
Add frontend testing, require node 12 (#15315)
- Add basic frontend unit testing infrastructure using jest in ESM mode - Rename 'make test' to 'make test-backend' - Introduce 'make test-frontend' and 'make test' that runs both - Bump Node.js requirement to v12. v10 will be EOL in less than a month. - Convert all build-related JS files to ESM. I opted to run frontend tests run as part of the compliance pipeline because they complete fast and are not platform-specific like the golang tests.
Diffstat (limited to 'build')
-rwxr-xr-xbuild/generate-images.js15
-rwxr-xr-xbuild/generate-svg.js13
2 files changed, 13 insertions, 15 deletions
diff --git a/build/generate-images.js b/build/generate-images.js
index bea36321e3..d82f21564f 100755
--- a/build/generate-images.js
+++ b/build/generate-images.js
@@ -1,12 +1,11 @@
-#!/usr/bin/env node
-'use strict';
-
-const imageminZopfli = require('imagemin-zopfli');
-const {optimize, extendDefaultPlugins} = require('svgo');
-const {fabric} = require('fabric');
-const {readFile, writeFile} = require('fs').promises;
-const {resolve} = require('path');
+import imageminZopfli from 'imagemin-zopfli';
+import {optimize, extendDefaultPlugins} from 'svgo';
+import {fabric} from 'fabric';
+import {readFile, writeFile} from 'fs/promises';
+import {resolve, dirname} from 'path';
+import {fileURLToPath} from 'url';
+const __dirname = dirname(fileURLToPath(import.meta.url));
const logoFile = resolve(__dirname, '../assets/logo.svg');
function exit(err) {
diff --git a/build/generate-svg.js b/build/generate-svg.js
index 97053a2958..3e14f906e3 100755
--- a/build/generate-svg.js
+++ b/build/generate-svg.js
@@ -1,11 +1,10 @@
-#!/usr/bin/env node
-'use strict';
-
-const fastGlob = require('fast-glob');
-const {optimize, extendDefaultPlugins} = require('svgo');
-const {resolve, parse} = require('path');
-const {readFile, writeFile, mkdir} = require('fs').promises;
+import fastGlob from 'fast-glob';
+import {optimize, extendDefaultPlugins} from 'svgo';
+import {resolve, parse, dirname} from 'path';
+import {readFile, writeFile, mkdir} from 'fs/promises';
+import {fileURLToPath} from 'url';
+const __dirname = dirname(fileURLToPath(import.meta.url));
const glob = (pattern) => fastGlob.sync(pattern, {cwd: resolve(__dirname), absolute: true});
const outputDir = resolve(__dirname, '../public/img/svg');