Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build.js: make use of mkdir's recursive option #2627

Merged
merged 1 commit into from
Oct 3, 2019
Merged
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
33 changes: 19 additions & 14 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,17 @@ function githubLinks (options) {
}
}

// This function builds the layouts folder for all the Stylus files.
// This function builds the static/css folder for all the Stylus files.
function buildCSS () {
console.log('[stylus] static/css started')
const labelForBuild = '[stylus] static/css finished'
console.time(labelForBuild)

fs.mkdir(path.join(__dirname, 'build'), () => {
fs.mkdir(path.join(__dirname, 'build/static'), () => {
fs.mkdir(path.join(__dirname, 'build/static/css'), () => {
fs.mkdir(path.join(__dirname, 'build/static/css'), { recursive: true }, (err) => {
if (err) {
throw err
}

fs.readFile(path.join(__dirname, 'layouts/css/styles.styl'), 'utf8', (err, data) => {
if (err) {
throw err
Expand All @@ -269,21 +271,24 @@ function buildCSS () {
})
})
})
})
})
}

// This function copies the rest of the static assets to their subfolder in the
// build directory.
function copyStatic () {
console.log('[metalsmith] build/static started')
console.time('[metalsmith] build/static finished')
fs.mkdir(path.join(__dirname, 'build'), () => {
fs.mkdir(path.join(__dirname, 'build', 'static'), () => {
ncp(path.join(__dirname, 'static'), path.join(__dirname, 'build', 'static'), (err) => {
if (err) { return console.error(err) }
console.timeEnd('[metalsmith] build/static finished')
})
console.log('[ncp] build/static started')
const labelForBuild = '[ncp] build/static finished'
console.time(labelForBuild)
fs.mkdir(path.join(__dirname, 'build/static'), { recursive: true }, (err) => {
if (err) {
throw err
}

ncp(path.join(__dirname, 'static'), path.join(__dirname, 'build/static'), (error) => {
if (error) {
return console.error(error)
}
console.timeEnd(labelForBuild)
})
})
}
Expand Down