prettier-plugin-packagejson
Advanced tools
Comparing version 2.4.3 to 2.4.4
const { runAsWorker } = require('synckit') | ||
runAsWorker(async (id, path, args) => { | ||
const root = await import(id) | ||
const method = path.pop() | ||
const receiver = path.reduce((acc, cur) => acc[cur], root) | ||
return receiver[method](...args) | ||
const { receiver, prop } = path.reduce( | ||
({ receiver, prop }, cur) => ({ | ||
receiver: receiver[prop], | ||
prop: cur, | ||
}), | ||
{ | ||
receiver: await import(id), | ||
prop: path.shift(), | ||
}, | ||
) | ||
return receiver[prop].apply(receiver, args) | ||
}) |
@@ -11,2 +11,8 @@ const requireSafe = require('./require') | ||
function testPath(path) { | ||
return /(^|\\|\/)package\.json$/.test(path) | ||
} | ||
exports.testPath = testPath | ||
/** @type {import('prettier').Plugin['parsers']} */ | ||
@@ -17,3 +23,2 @@ exports.parsers = { | ||
preprocess(text, options) { | ||
// istanbul ignore next | ||
if (parser.preprocess) { | ||
@@ -23,7 +28,5 @@ text = parser.preprocess(text, options) | ||
return options.filepath && /(^|\\|\/)package\.json$/.test(options.filepath) | ||
? sortPackageJson.default(text) | ||
: text | ||
return testPath(options.filepath) ? sortPackageJson.default(text) : text | ||
}, | ||
}, | ||
} |
module.exports = path => { | ||
try { | ||
return require(path) | ||
} catch (error) {} | ||
} catch {} | ||
} |
{ | ||
"name": "prettier-plugin-packagejson", | ||
"version": "2.4.3", | ||
"version": "2.4.4", | ||
"description": "Prettier package.json plugin to make the order of properties nice.", | ||
@@ -27,12 +27,13 @@ "keywords": [ | ||
"test": "run-s lint test:*", | ||
"test:unit": "jest" | ||
"test:unit": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" | ||
}, | ||
"dependencies": { | ||
"sort-package-json": "2.4.1", | ||
"sort-package-json": "2.5.0", | ||
"synckit": "0.8.5" | ||
}, | ||
"devDependencies": { | ||
"jest": "29.4.2", | ||
"cross-env": "7.0.3", | ||
"jest": "29.5.0", | ||
"npm-run-all": "4.1.5", | ||
"prettier": "2.8.4" | ||
"prettier": "2.8.8" | ||
}, | ||
@@ -39,0 +40,0 @@ "peerDependencies": { |
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
4948
59
4
+ Addedget-stdin@9.0.0(transitive)
+ Addedsort-package-json@2.5.0(transitive)
- Removedsort-package-json@2.4.1(transitive)
Updatedsort-package-json@2.5.0