From 32ac169906cc4ae7a3105b36cd612dbeff021b22 Mon Sep 17 00:00:00 2001 From: Maddy <12754347+MaddyDev@users.noreply.github.com> Date: Thu, 6 Feb 2020 16:45:10 -0800 Subject: [PATCH] Task/check file length (#9047) * add filelength task to vscodeTasks * added to package task instead of build * testing for failures with reduced limits * reverted to actual lengths --- build/gulpfile.vscode.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index af42d520d3..8f739c92c0 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -275,6 +275,9 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op } let result = all + .pipe(fileLengthFilter) + .pipe(filelength) + .pipe(fileLengthFilter.restore) .pipe(util.skipDirectories()) .pipe(util.fixWin32DirectoryPermissions()) .pipe(electron(_.extend({}, config, { platform, arch, ffmpegChromium: true }))) @@ -329,6 +332,29 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op }; } +const fileLengthFilter = filter([ + '**', + '!extensions/import/*.docx', + '!extensions/admin-tool-ext-win/license/**' +], {restore: true}); + +const filelength = es.through(function (file) { + + const fileName = path.basename(file.relative); + const fileDir = path.dirname(file.relative); + //check the filename is < 50 characters (basename gets the filename with extension). + if (fileName.length > 50) { + console.error(`File name '${fileName}' under ${fileDir} is too long. Rename file to have less than 50 characters.`); + throw new Error('File name exceeds acceptable length of 50 characters: ' + fileName); + } + if (file.relative.length > 150) { + console.error(`File path ${file.relative} exceeds acceptable file-length. Rename the path to have less than 150 characters.`); + throw new Error('File path exceeds acceptable path-length of 150 characters: ' + file.relative); + } + + this.emit('data', file); +}); + const buildRoot = path.dirname(root); const BUILD_TARGETS = [