From d79423c7285d4ef8dcf615f5cfb01ce20f959578 Mon Sep 17 00:00:00 2001 From: Maddy <12754347+MaddyDev@users.noreply.github.com> Date: Fri, 25 Oct 2019 14:30:43 -0700 Subject: [PATCH] Task/checkfile length (#7959) * add hygiene task to test file length * check for the filename length instead of the path * formatted the error message * added check for entire path including directories * error messaged fixed * check relative length for 150 as agreed upon * error message to include 150 * added file length filter * check the file length seperately * ffsdfsdf * remove the test file * move it to last * restore the filtered files for further checks * removed comment * test * test * remove the test file * test commit * remove the test file * restore fileLengthFilter * test * remove the testfile * revert * xfgdgdfg * huh * test file * revert. * add all to the filter --- build/gulpfile.hygiene.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/build/gulpfile.hygiene.js b/build/gulpfile.hygiene.js index 52bdd24b23..7842c1f58e 100644 --- a/build/gulpfile.hygiene.js +++ b/build/gulpfile.hygiene.js @@ -249,6 +249,12 @@ const tslintHygieneFilter = [ ...tslintBaseFilter ]; +const fileLengthFilter = filter([ + '**', + '!extensions/import/*.docx', + '!extensions/admin-tool-ext-win/license/**' +], {restore: true}); + const copyrightHeaderLines = [ '/*---------------------------------------------------------------------------------------------', ' * Copyright (c) Microsoft Corporation. All rights reserved.', @@ -387,6 +393,23 @@ function hygiene(some) { }); }); + 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.`); + errorCount++; + } + if (file.relative.length > 150) { + console.error(`File path ${file.relative} exceeds acceptable file-length. Rename the path to have less than 150 characters.`); + errorCount++; + } + + this.emit('data', file); + }); + const tslintConfiguration = tslint.Configuration.findConfiguration('tslint.json', '.'); const tslintOptions = { fix: false, formatter: 'json' }; const tsLinter = new tslint.Linter(tslintOptions); @@ -418,6 +441,9 @@ function hygiene(some) { const productJsonFilter = filter('product.json', { restore: true }); const result = input + .pipe(fileLengthFilter) + .pipe(filelength) + .pipe(fileLengthFilter.restore) .pipe(filter(f => !f.stat.isDirectory())) .pipe(productJsonFilter) .pipe(process.env['BUILD_SOURCEVERSION'] ? es.through() : productJson)