Some checks failed
		
		
	
	backend / cross (aarch64) (push) Failing after 11m25s
				
			backend / cross (arm) (push) Failing after 7m16s
				
			backend / cross (armhf) (push) Failing after 2m5s
				
			backend / cross (i686) (push) Failing after 31s
				
			backend / cross (mips) (push) Failing after 31s
				
			backend / cross (mips64) (push) Failing after 31s
				
			backend / cross (mips64el) (push) Failing after 2m49s
				
			backend / cross (s390x) (push) Failing after 6m45s
				
			backend / cross (mipsel) (push) Failing after 16m40s
				
			backend / cross (win32) (push) Failing after 7m0s
				
			backend / cross (x86_64) (push) Failing after 17m57s
				
			frontend / build (push) Failing after 5m51s
				
			
		
			
				
	
	
		
			69 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			69 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const { src, dest, task, series } = require('gulp');
 | 
						|
const clean = require('gulp-clean');
 | 
						|
const gzip = require('gulp-gzip');
 | 
						|
const inlineSource = require('gulp-inline-source');
 | 
						|
const rename = require('gulp-rename');
 | 
						|
const through2 = require('through2');
 | 
						|
 | 
						|
const genHeader = (size, buf, len) => {
 | 
						|
    let idx = 0;
 | 
						|
    let data = 'unsigned char index_html[] = {\n  ';
 | 
						|
 | 
						|
    for (const value of buf) {
 | 
						|
        idx++;
 | 
						|
 | 
						|
        const current = value < 0 ? value + 256 : value;
 | 
						|
 | 
						|
        data += '0x';
 | 
						|
        data += (current >>> 4).toString(16);
 | 
						|
        data += (current & 0xf).toString(16);
 | 
						|
 | 
						|
        if (idx === len) {
 | 
						|
            data += '\n';
 | 
						|
        } else {
 | 
						|
            data += idx % 12 === 0 ? ',\n  ' : ', ';
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    data += '};\n';
 | 
						|
    data += `unsigned int index_html_len = ${len};\n`;
 | 
						|
    data += `unsigned int index_html_size = ${size};\n`;
 | 
						|
    return data;
 | 
						|
};
 | 
						|
let fileSize = 0;
 | 
						|
 | 
						|
task('clean', () => {
 | 
						|
    return src('dist', { read: false, allowEmpty: true }).pipe(clean());
 | 
						|
});
 | 
						|
 | 
						|
task('inline', () => {
 | 
						|
    const options = {
 | 
						|
        compress: false,
 | 
						|
    };
 | 
						|
 | 
						|
    return src('dist/index.html').pipe(inlineSource(options)).pipe(rename('inline.html')).pipe(dest('dist/'));
 | 
						|
});
 | 
						|
 | 
						|
task(
 | 
						|
    'default',
 | 
						|
    series('inline', () => {
 | 
						|
        return src('dist/inline.html')
 | 
						|
            .pipe(
 | 
						|
                through2.obj((file, enc, cb) => {
 | 
						|
                    fileSize = file.contents.length;
 | 
						|
                    return cb(null, file);
 | 
						|
                })
 | 
						|
            )
 | 
						|
            .pipe(gzip())
 | 
						|
            .pipe(
 | 
						|
                through2.obj((file, enc, cb) => {
 | 
						|
                    const buf = file.contents;
 | 
						|
                    file.contents = Buffer.from(genHeader(fileSize, buf, buf.length));
 | 
						|
                    return cb(null, file);
 | 
						|
                })
 | 
						|
            )
 | 
						|
            .pipe(rename('html.h'))
 | 
						|
            .pipe(dest('../src/'));
 | 
						|
    })
 | 
						|
);
 |