unified-engine
Advanced tools
Comparing version 8.1.0 to 8.2.0
'use strict' | ||
var path = require('path') | ||
var Module = require('module') | ||
var yaml = require('js-yaml') | ||
@@ -11,3 +10,3 @@ var json = require('parse-json') | ||
var fault = require('fault') | ||
var FindUp = require('./find-up') | ||
var FindUp = require('./find-up.js') | ||
@@ -20,3 +19,5 @@ module.exports = Config | ||
'.json': loadJson, | ||
'.js': loadScript, | ||
'.cjs': loadScriptOrModule, | ||
'.mjs': loadScriptOrModule, | ||
'.js': loadScriptOrModule, | ||
'.yaml': loadYaml, | ||
@@ -90,4 +91,8 @@ '.yml': loadYaml | ||
var result = {settings: {}, plugins: []} | ||
var contents = buf ? fn.apply(self, arguments) : undefined | ||
var contents | ||
if (filePath) { | ||
contents = await fn.apply(self, arguments) | ||
} | ||
if (self.configTransform && contents !== undefined) { | ||
@@ -127,16 +132,4 @@ contents = self.configTransform(contents, filePath) | ||
// Basically `Module.prototype.load`, but for a buffer instead of a file path. | ||
function loadScript(buf, filePath) { | ||
var submodule = Module._cache[filePath] | ||
if (!submodule) { | ||
submodule = new Module(filePath, module) | ||
submodule.filename = filePath | ||
submodule.paths = Module._nodeModulePaths(path.dirname(filePath)) | ||
submodule._compile(String(buf), filePath) | ||
submodule.loaded = true | ||
Module._cache[filePath] = submodule | ||
} | ||
return submodule.exports | ||
function loadScriptOrModule(_, filePath) { | ||
return loadFromAbsolutePath(filePath, this.cwd) | ||
} | ||
@@ -220,34 +213,7 @@ | ||
var fp = loadPlugin.resolve(id, {cwd: options.root, prefix: options.prefix}) | ||
var ext | ||
var result | ||
if (fp) { | ||
ext = path.extname(fp) | ||
result = await loadFromAbsolutePath(fp, options.root) | ||
/* istanbul ignore next - To do next major: Tests don’t run on Node 10 */ | ||
if (ext !== '.mjs') { | ||
try { | ||
result = require(fp) | ||
} catch (error) { | ||
if (ext !== '.cjs' && error.code === 'ERR_REQUIRE_ESM') { | ||
ext = '.mjs' | ||
} else { | ||
throw fault( | ||
'Cannot parse script `%s`\n%s', | ||
path.relative(options.root, fp), | ||
error.stack | ||
) | ||
} | ||
} | ||
if (result && typeof result === 'object' && result.__esModule) { | ||
result = result.default | ||
} | ||
} | ||
/* istanbul ignore next - To do next major: Tests don’t run on Node 10 */ | ||
if (ext === '.mjs') { | ||
result = (await import(fp)).default | ||
} | ||
try { | ||
@@ -316,1 +282,34 @@ if (typeof result === 'function') { | ||
} | ||
async function loadFromAbsolutePath(fp, base) { | ||
var ext = path.extname(fp) | ||
var result | ||
/* istanbul ignore next - To do next major: Tests don’t run on Node 10 */ | ||
if (ext !== '.mjs') { | ||
try { | ||
result = require(fp) | ||
} catch (error) { | ||
if (ext !== '.cjs' && error.code === 'ERR_REQUIRE_ESM') { | ||
ext = '.mjs' | ||
} else { | ||
throw fault( | ||
'Cannot parse script `%s`\n%s', | ||
path.relative(base, fp), | ||
error.stack | ||
) | ||
} | ||
} | ||
if (result && typeof result === 'object' && result.__esModule) { | ||
result = result.default | ||
} | ||
} | ||
/* istanbul ignore next - To do next major: Tests don’t run on Node 10 */ | ||
if (ext === '.mjs') { | ||
result = (await import(fp)).default | ||
} | ||
return result | ||
} |
'use strict' | ||
var trough = require('trough') | ||
var read = require('./read') | ||
var configure = require('./configure') | ||
var parse = require('./parse') | ||
var transform = require('./transform') | ||
var queue = require('./queue') | ||
var stringify = require('./stringify') | ||
var copy = require('./copy') | ||
var stdout = require('./stdout') | ||
var fileSystem = require('./file-system') | ||
var read = require('./read.js') | ||
var configure = require('./configure.js') | ||
var parse = require('./parse.js') | ||
var transform = require('./transform.js') | ||
var queue = require('./queue.js') | ||
var stringify = require('./stringify.js') | ||
var copy = require('./copy.js') | ||
var stdout = require('./stdout.js') | ||
var fileSystem = require('./file-system.js') | ||
@@ -14,0 +14,0 @@ // This pipeline ensures each of the pipes always runs: even if the read pipe |
'use strict' | ||
var Configuration = require('../configuration') | ||
var Configuration = require('../configuration.js') | ||
@@ -5,0 +5,0 @@ module.exports = configure |
'use strict' | ||
var Ignore = require('../ignore') | ||
var find = require('../finder') | ||
var Ignore = require('../ignore.js') | ||
var find = require('../finder.js') | ||
@@ -6,0 +6,0 @@ module.exports = fileSystem |
'use strict' | ||
var trough = require('trough') | ||
var configure = require('./configure') | ||
var fileSystem = require('./file-system') | ||
var stdin = require('./stdin') | ||
var transform = require('./transform') | ||
var log = require('./log') | ||
var configure = require('./configure.js') | ||
var fileSystem = require('./file-system.js') | ||
var stdin = require('./stdin.js') | ||
var transform = require('./transform.js') | ||
var log = require('./log.js') | ||
@@ -10,0 +10,0 @@ module.exports = trough() |
'use strict' | ||
var FileSet = require('../file-set') | ||
var filePipeline = require('../file-pipeline') | ||
var FileSet = require('../file-set.js') | ||
var filePipeline = require('../file-pipeline/index.js') | ||
@@ -6,0 +6,0 @@ module.exports = transform |
@@ -7,3 +7,3 @@ 'use strict' | ||
var debug = require('debug')('unified-engine:find-up') | ||
var wrap = require('trough/wrap') | ||
var wrap = require('trough/wrap.js') | ||
@@ -10,0 +10,0 @@ module.exports = FindUp |
@@ -5,3 +5,3 @@ 'use strict' | ||
var gitignore = require('ignore') | ||
var FindUp = require('./find-up') | ||
var FindUp = require('./find-up.js') | ||
@@ -8,0 +8,0 @@ module.exports = Ignore |
@@ -5,3 +5,3 @@ 'use strict' | ||
var statistics = require('vfile-statistics') | ||
var fileSetPipeline = require('./file-set-pipeline') | ||
var fileSetPipeline = require('./file-set-pipeline/index.js') | ||
@@ -8,0 +8,0 @@ module.exports = run |
{ | ||
"name": "unified-engine", | ||
"version": "8.1.0", | ||
"version": "8.2.0", | ||
"description": "Engine to process multiple files with unified", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
7
64103
1720