Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: make it possible to omit glob dependency
PR-URL: #192
Credit: @bcoe
Close: #192
Reviewed-by: @isaacs
  • Loading branch information
bcoe authored and isaacs committed Aug 14, 2019
1 parent 9442819 commit dc1682d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rimraf.js
Expand Up @@ -4,7 +4,12 @@ rimraf.sync = rimrafSync
var assert = require("assert")
var path = require("path")
var fs = require("fs")
var glob = require("glob")
let glob = undefined

This comment has been minimized.

Copy link
@hellamps

hellamps Aug 14, 2019

It's breaking compatibility with old node versions at least:

node_modules/metalsmith/node_modules/rimraf/rimraf.js:7
let glob = undefined
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js17)

This comment has been minimized.

Copy link
@balihoo-cnorwood
try {
glob = require("glob")
} catch (_err) {
// treat glob as optional.
}
var _0666 = parseInt('666', 8)

var defaultGlobOpts = {
Expand Down Expand Up @@ -37,6 +42,9 @@ function defaults (options) {
if (options.glob === false) {
options.disableGlob = true
}
if (options.disableGlob !== true && glob === undefined) {
throw Error('glob dependency not found, set `options.disableGlob = true` if intentional')
}
options.disableGlob = options.disableGlob || false
options.glob = options.glob || defaultGlobOpts
}
Expand Down

0 comments on commit dc1682d

Please sign in to comment.