From: XhmikosR Date: Mon, 11 May 2020 15:01:18 +0000 (+0300) Subject: Improve build/zip-examples.js (#30759) X-Git-Tag: v5.0.0-alpha1~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf06347020c10ba97976dfeff5cd0ac8c27e5ea1;p=thirdparty%2Fbootstrap.git Improve build/zip-examples.js (#30759) * remove favicons meta tags * copy the two brand images we use in the examples * opy dist and brand images into an assets folder --- diff --git a/build/zip-examples.js b/build/zip-examples.js index 0ac64e573c..c089036d6e 100644 --- a/build/zip-examples.js +++ b/build/zip-examples.js @@ -19,7 +19,7 @@ const folderName = `bootstrap-${version}-examples` sh.config.fatal = true if (!sh.test('-d', '_gh_pages')) { - throw new Error('The _gh_pages folder does not exist, did you forget building the docs?') + throw new Error('The "_gh_pages" folder does not exist, did you forget building the docs?') } // switch to the root dir @@ -27,21 +27,29 @@ sh.cd(path.join(__dirname, '..')) // remove any previously created folder with the same name sh.rm('-rf', folderName) +// create any folders so that `cp` works sh.mkdir('-p', folderName) - -// copy the examples and dist folders; for the examples we use `*` -// so that its content are copied to the root dist dir -sh.cp('-Rf', [ - `_gh_pages/docs/${versionShort}/examples/*`, - `_gh_pages/docs/${versionShort}/dist/` -], folderName) +sh.mkdir('-p', `${folderName}/assets/brand/`) + +sh.cp('-Rf', `_gh_pages/docs/${versionShort}/examples/*`, folderName) +sh.cp('-Rf', `_gh_pages/docs/${versionShort}/dist/`, `${folderName}/assets/`) +// also copy the two brand images we use in the examples +sh.cp('-f', [ + `_gh_pages/docs/${versionShort}/assets/brand/bootstrap-outline.svg`, + `_gh_pages/docs/${versionShort}/assets/brand/bootstrap-solid.svg` +], `${folderName}/assets/brand/`) sh.rm(`${folderName}/index.html`) -// sed-fu +// get all examples' HTML files sh.find(`${folderName}/**/*.html`).forEach(file => { - sh.sed('-i', new RegExp(`"/docs/${versionShort}/`, 'g'), '"../', file) - sh.sed('-i', /(/g, '$1>', file) - sh.sed('-i', /(', file) + const fileContents = sh.cat(file) + .toString() + .replace(new RegExp(`"/docs/${versionShort}/`, 'g'), '"../') + .replace(/"..\/dist\//g, '"../assets/dist/') + .replace(/(/g, '$1>') + .replace(/(') + .replace(/( +)