aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2020-05-11 18:01:18 +0300
committerXhmikosR <[email protected]>2020-05-12 19:21:36 +0300
commitdf91d2cab016c104f007b6e2b7bf93245e401f9d (patch)
tree1236e99e492c88e714e8eda870b39bfca9db1ae7
parentd2f9fbd055c8a53779b432ac50b894b49b114a22 (diff)
downloadbootstrap-df91d2cab016c104f007b6e2b7bf93245e401f9d.tar.xz
bootstrap-df91d2cab016c104f007b6e2b7bf93245e401f9d.zip
Improve build/zip-examples.js (#30759)
* remove favicons meta tags * copy the two brand images we use in the examples * copy dist and brand images into an assets folder
-rw-r--r--build/zip-examples.js32
1 files changed, 20 insertions, 12 deletions
diff --git a/build/zip-examples.js b/build/zip-examples.js
index 884044fd8..3f7fb9abb 100644
--- a/build/zip-examples.js
+++ b/build/zip-examples.js
@@ -21,7 +21,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
@@ -29,21 +29,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', /(<link href="\.\.\/.*) integrity=".*>/g, '$1>', file)
- sh.sed('-i', /(<script src="\.\.\/.*) integrity=".*>/g, '$1></script>', file)
+ const fileContents = sh.cat(file)
+ .toString()
+ .replace(new RegExp(`"/docs/${versionShort}/`, 'g'), '"../')
+ .replace(/"..\/dist\//g, '"../assets/dist/')
+ .replace(/(<link href="\.\.\/.*) integrity=".*>/g, '$1>')
+ .replace(/(<script src="\.\.\/.*) integrity=".*>/g, '$1></script>')
+ .replace(/( +)<!-- favicons(.|\n)+<style>/i, ' <style>')
+ new sh.ShellString(fileContents).to(file)
})
// create the zip file