Skip to content

Commit

Permalink
build: replace 'string' package dependency with custom function to ch…
Browse files Browse the repository at this point in the history
…eck is a file ends with '.html' or not
  • Loading branch information
aleks-elkin committed Jul 29, 2021
1 parent 306d534 commit 0309e94
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
9 changes: 4 additions & 5 deletions docs/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const bsshooter = require('./tasks/shooter.js');
const cheerio = require('cheerio');
const path = require('path');
const fs = require('fs');
const S = require('string');

var stackconf = {
username: process.env.BROWSERSTACK_USERNAME,
Expand Down Expand Up @@ -468,10 +467,13 @@ module.exports = function(grunt) {
});
return pagesIndex;
}
function isHTMLFile(filename) {
return filename.substring(filename.length - 5, filename.length) === '.html';
}
function processFile(abspath, filename) {
var pageIndex;

if (S(filename).endsWith('.html')) {
if (isHTMLFile(filename)) {
pageIndex = processHTMLFile(abspath, filename);
}
return pageIndex;
Expand All @@ -488,7 +490,6 @@ module.exports = function(grunt) {
if (!(raw.includes('robots') && raw.includes('noindex'))) {
var content = ignoreHTML(raw);

// var title = require('string')(raw).between('<title>', '</title>').s;
var title;
var left = '<title>';
var right = '</title>';
Expand All @@ -502,13 +503,11 @@ module.exports = function(grunt) {
title = raw.slice(startPos + left.length, endPos);
}

// var href = require('string')(abspath).chompLeft(prefix).s;
var href = abspath;
if (abspath.indexOf(prefix) === 0) {
href = abspath.slice(prefix.length);
}

// content = require('string')(content).trim().stripTags().stripPunctuation().s;
content = content
.trim()
.replace(RegExp('</?[^<>]*>', 'gi'), '')
Expand Down
29 changes: 15 additions & 14 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"less": "^3.9.0",
"load-grunt-tasks": "^3.5.0",
"selenium-webdriver": "^3.3.0",
"serve-static": "^1.12.4",
"string": "^3.3.3"
"serve-static": "^1.12.4"
}
}

0 comments on commit 0309e94

Please sign in to comment.