Skip to content

Commit

Permalink
[fix] stop less grunt runner on missing files
Browse files Browse the repository at this point in the history
The less grunt runner silently ignore missing files and continue with the build[1]::

    Running "less:production" (less) task
    >> Destination css/searxng.min.css not written because no source files were found.
    >> 1 stylesheet created.
    >> 1 sourcemap created.

Add filter function that calls grunt.fail() if the scr file does not exists.

[1] searxng#750 (comment)
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
  • Loading branch information
return42 authored and not-my-profile committed Jan 15, 2022
1 parent 2e85744 commit 1093354
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions searx/static/themes/simple/gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ module.exports = function (grunt) {

const eachAsync = require('each-async');

function file_exists (filepath) {
// filter function to exit grunt task with error if a (src) file not exists
if (!grunt.file.exists(filepath)) {
grunt.fail.fatal('Could not find: ' + filepath, 42);
} else {
return true;
}
}

grunt.initConfig({

_brand: '../../../../src/brand',
Expand Down Expand Up @@ -116,10 +125,20 @@ module.exports = function (grunt) {
sourceMapURL: (name) => { const s = name.split('/'); return s[s.length - 1] + '.map'; },
outputSourceFiles: true,
},
files: {
"css/searxng.min.css": "src/less/style.less",
"css/searxng-rtl.min.css": "src/less/style-rtl.less"
}
files: [
{
src: ['src/less/style.less'],
dest: 'css/searxng.min.css',
nonull: true,
filter: file_exists,
},
{
src: ['src/less/style-rtl.less'],
dest: 'css/searxng-rtl.min.css',
nonull: true,
filter: file_exists,
},
],
},
},
image: {
Expand Down

0 comments on commit 1093354

Please sign in to comment.