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

Add graceful-fs. #3700

Merged
merged 2 commits into from
Apr 29, 2021
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
13 changes: 9 additions & 4 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// BUILD.JS: This file is responsible for building static HTML pages

const fs = require('fs')
const gracefulFs = require('graceful-fs')
const path = require('path')
const Metalsmith = require('metalsmith')
const collections = require('metalsmith-collections')
Expand Down Expand Up @@ -32,6 +33,10 @@ const anchorMarkdownHeadings = require('./scripts/plugins/anchor-markdown-headin
const loadVersions = require('./scripts/load-versions')
const latestVersion = require('./scripts/helpers/latestversion')

// This is needed at least on Windows to prevent the `EMFILE: too many open files` error
// https://github.com/isaacs/node-graceful-fs#global-patching
gracefulFs.gracefulify(fs)

// Set the default language, also functions as a fallback for properties which
// are not defined in the given language.
const DEFAULT_LANG = 'en'
Expand Down Expand Up @@ -214,7 +219,7 @@ function buildCSS () {
outputStyle: process.env.NODE_ENV !== 'development' ? 'compressed' : 'expanded'
}

fs.mkdir(path.join(__dirname, 'build/static/css'), { recursive: true }, (err) => {
gracefulFs.mkdir(path.join(__dirname, 'build/static/css'), { recursive: true }, (err) => {
if (err) {
throw err
}
Expand All @@ -229,7 +234,7 @@ function buildCSS () {
console.warn(warn.toString())
})

fs.writeFile(dest, res.css, (err) => {
gracefulFs.writeFile(dest, res.css, (err) => {
if (err) {
throw err
}
Expand All @@ -247,7 +252,7 @@ function copyStatic () {
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) => {
gracefulFs.mkdir(path.join(__dirname, 'build/static'), { recursive: true }, (err) => {
if (err) {
throw err
}
Expand Down Expand Up @@ -300,7 +305,7 @@ function fullBuild (opts) {
if (err) { throw err }

// Executes the build cycle for every locale.
fs.readdir(path.join(__dirname, 'locale'), (e, locales) => {
gracefulFs.readdir(path.join(__dirname, 'locale'), (e, locales) => {
if (e) {
throw e
}
Expand Down
6 changes: 3 additions & 3 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 @@ -39,6 +39,7 @@
"autoprefixer": "^10.2.5",
"cheerio": "^0.22.0",
"fibers": "^5.0.0",
"graceful-fs": "^4.2.6",
"handlebars": "^4.7.7",
"jstransformer-handlebars": "^1.1.0",
"junk": "^3.1.0",
Expand Down