Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions __mocks__/fs-extra-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function rimraf(dirPath) {
}

/**
* Iterativelts creates directories to the file or directory
* Iteratively creates directories to the file or directory
* @param pathArg
*/
function createDir(pathArg) {
Expand Down Expand Up @@ -75,6 +75,27 @@ function copyDirSync(src, dest) {
}
}

/**
* Utility function to copy a directory to a destination recursively for copyAsync
*/
function copyDirAsync(src, dest) {
if (fs.lstatSync(src).isDirectory()) {
const files = fs.readdirSync(src);
files.forEach((file) => {
const curSource = path.join(src, file);
const curDest = path.join(dest, file);
if (fs.lstatSync(curSource).isDirectory()) {
if (!fs.existsSync(curDest)) {
createDir(curDest);
}
copyDirAsync(curSource, curDest);
} else {
fs.copyAsync(curSource, curDest);
}
});
}
}

/**
* Mocks
*/
Expand Down Expand Up @@ -143,7 +164,16 @@ fs.removeAsync = pathArg => new Promise((resolve, reject) => {
*/
fs.copyAsync = (src, dest) => new Promise((resolve, reject) => {
try {
fs.copySync(src, dest);
// copyAsync creates folders to a destination path if they do not exist
const dirPath = path.dirname(dest);
if (!fs.existsSync(dirPath)) {
createDir(dirPath);
}
if (fs.lstatSync(src).isDirectory()) {
copyDirAsync(src, dest);
} else {
copyFileSync(src, dest);
}
resolve();
} catch (err) {
reject(err);
Expand Down
5 changes: 0 additions & 5 deletions asset/css/font-awesome.min.css

This file was deleted.

Binary file removed asset/fonts/fa-brands-400.eot
Binary file not shown.
1,127 changes: 0 additions & 1,127 deletions asset/fonts/fa-brands-400.svg

This file was deleted.

Binary file removed asset/fonts/fa-brands-400.ttf
Binary file not shown.
Binary file removed asset/fonts/fa-brands-400.woff
Binary file not shown.
Binary file removed asset/fonts/fa-brands-400.woff2
Binary file not shown.
Binary file removed asset/fonts/fa-regular-400.eot
Binary file not shown.
467 changes: 0 additions & 467 deletions asset/fonts/fa-regular-400.svg

This file was deleted.

Binary file removed asset/fonts/fa-regular-400.ttf
Binary file not shown.
Binary file removed asset/fonts/fa-regular-400.woff
Binary file not shown.
Binary file removed asset/fonts/fa-regular-400.woff2
Binary file not shown.
Binary file removed asset/fonts/fa-solid-900.eot
Binary file not shown.
2,231 changes: 0 additions & 2,231 deletions asset/fonts/fa-solid-900.svg

This file was deleted.

Binary file removed asset/fonts/fa-solid-900.ttf
Binary file not shown.
Binary file removed asset/fonts/fa-solid-900.woff
Binary file not shown.
Binary file removed asset/fonts/fa-solid-900.woff2
Binary file not shown.
5 changes: 5 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"author": "Jiang Sheng <gisonrg@gmail.com>",
"license": "MIT",
"dependencies": {
"@fortawesome/fontawesome-free": "^5.7.2",
"@sindresorhus/slugify": "^0.8.0",
"bluebird": "^3.4.7",
"chalk": "^1.1.3",
Expand Down
28 changes: 21 additions & 7 deletions src/Site.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,10 @@ Site.prototype.createPage = function (config) {
path.join(this.siteAssetsDestPath, 'css', 'bootstrap-vue.min.css')),
externalScripts: _.union(this.siteConfig.externalScripts, config.externalScripts),
fontAwesome: path.relative(path.dirname(resultPath),
path.join(this.siteAssetsDestPath, 'css', 'font-awesome.min.css')),
path.join(this.siteAssetsDestPath, 'fontawesome', 'css', 'all.min.css')),
glyphicons: path.relative(path.dirname(resultPath),
path.join(this.siteAssetsDestPath, 'css', 'bootstrap-glyphicons.min.css')),
path.join(this.siteAssetsDestPath, 'glyphicons', 'css',
'bootstrap-glyphicons.min.css')),
highlight: path.relative(path.dirname(resultPath),
path.join(this.siteAssetsDestPath, 'css', 'github.min.css')),
markbind: path.relative(path.dirname(resultPath),
Expand Down Expand Up @@ -520,6 +521,7 @@ Site.prototype.generate = function (baseUrl) {
.then(() => this.buildAssets())
.then(() => this.buildSourceFiles())
.then(() => this.copyMarkBindAsset())
.then(() => this.copyFontAwesomeAsset())
.then(() => this.copyLayouts())
.then(() => this.updateSiteData())
.then(() => {
Expand Down Expand Up @@ -811,12 +813,24 @@ Site.prototype.updateSiteData = function (filePaths) {
this.writeSiteData();
};

/**
* Copies Font Awesome assets to the assets folder
*/
Site.prototype.copyFontAwesomeAsset = function () {
const faRootSrcPath = path.join(__dirname, '..', 'node_modules', '@fortawesome', 'fontawesome-free');
const faCssSrcPath = path.join(faRootSrcPath, 'css', 'all.min.css');
Comment thread
yamgent marked this conversation as resolved.
const faCssDestPath = path.join(this.siteAssetsDestPath, 'fontawesome', 'css', 'all.min.css');
const faFontsSrcPath = path.join(faRootSrcPath, 'webfonts');
const faFontsDestPath = path.join(this.siteAssetsDestPath, 'fontawesome', 'webfonts');

return fs.copyAsync(faCssSrcPath, faCssDestPath).then(fs.copyAsync(faFontsSrcPath, faFontsDestPath));
};

/**
* Copies MarkBind assets to the assets folder
*/
Site.prototype.copyMarkBindAsset = function () {
return new Promise((resolve, reject) => {
fs.copyAsync(this.siteAssetsSrcPath, this.siteAssetsDestPath)
.then(resolve)
.catch(reject);
});
return fs.copyAsync(this.siteAssetsSrcPath, this.siteAssetsDestPath);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions test/functional/test_site/expected/bugs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<title>Open Bugs</title>
<link rel="stylesheet" href="../markbind/css/bootstrap.min.css">
<link rel="stylesheet" href="../markbind/css/bootstrap-vue.min.css">
<link rel="stylesheet" href="../markbind/css/font-awesome.min.css" >
<link rel="stylesheet" href="../markbind/css/bootstrap-glyphicons.min.css" >
<link rel="stylesheet" href="../markbind/fontawesome/css/all.min.css" >
<link rel="stylesheet" href="../markbind/glyphicons/css/bootstrap-glyphicons.min.css" >
<link rel="stylesheet" href="../markbind/css/github.min.css">
<link rel="stylesheet" href="../markbind/css/markbind.css">
<link rel="stylesheet" href="STYLESHEET_LINK">
Expand Down
4 changes: 2 additions & 2 deletions test/functional/test_site/expected/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<title>Hello World</title>
<link rel="stylesheet" href="markbind/css/bootstrap.min.css">
<link rel="stylesheet" href="markbind/css/bootstrap-vue.min.css">
<link rel="stylesheet" href="markbind/css/font-awesome.min.css" >
<link rel="stylesheet" href="markbind/css/bootstrap-glyphicons.min.css" >
<link rel="stylesheet" href="markbind/fontawesome/css/all.min.css" >
<link rel="stylesheet" href="markbind/glyphicons/css/bootstrap-glyphicons.min.css" >
<link rel="stylesheet" href="markbind/css/github.min.css">
<link rel="stylesheet" href="markbind/css/markbind.css">
<link rel="stylesheet" href="STYLESHEET_LINK">
Expand Down

This file was deleted.

Large diffs are not rendered by default.

Binary file not shown.
Loading