Skip to content

Commit

Permalink
Fixes #141 - module.parent deprecated in Node 14+
Browse files Browse the repository at this point in the history
  • Loading branch information
jameelmoses committed Aug 29, 2022
1 parent 7d9d7e3 commit 44773ae
Show file tree
Hide file tree
Showing 5 changed files with 760 additions and 881 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ Credit largely goes to @sindresorhus for his [load-grunt-plugins](https://github

## Changelog

##### 2.0.8
- Fixes #141 - module.parent deprecated in Node 14+. Thanks @DaveyJake
- Update dependencies

##### 2.0.7
- Update dependencies

Expand Down
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = function(options) {

const DEBUG = options.DEBUG || false;
const pattern = getPattern(options);
const config = options.config || findup('package.json', { cwd: parentDir });
const config = options.config || findup('package.json', { cwd: path.dirname(module.parent.filename) });
const scope = arrayify(options.scope || ['dependencies', 'devDependencies', 'peerDependencies']);
const replaceString = options.replaceString || /^gulp(-|\.)/;
const camelizePluginName = options.camelize !== false;
Expand Down Expand Up @@ -167,7 +167,5 @@ module.exports = function(options) {
return finalObject;
};

const parentDir = path.dirname(module.parent.filename);

// Necessary to get the current `module.parent` and resolve paths correctly.
delete require.cache[__filename];
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-load-plugins",
"version": "2.0.7",
"version": "2.0.8",
"description": "Automatically load any gulp plugins in your package.json",
"scripts": {
"test": "yarn run lint && NODE_PATH=test/global_modules mocha",
Expand Down Expand Up @@ -43,23 +43,27 @@
],
"dependencies": {
"array-unique": "^0.3.2",
"fancy-log": "^1.2.0",
"findup-sync": "^4.0.0",
"gulplog": "^1.0.0",
"has-gulplog": "^0.1.0",
"fancy-log": "^2.0.0",
"findup-sync": "^5.0.0",
"gulplog": "^2.0.0",
"has-gulplog": "^1.0.0",
"micromatch": "^4.0.2",
"resolve": "^1.17.0"
},
"devDependencies": {
"capture-stream": "^0.1.2",
"eslint": "^7.7.0",
"eslint-config-standard": "^16.0.2",
"eslint": "^8.23.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-n": "^15.2.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-promise": "^6.0.1",
"eslint-plugin-standard": "^5.0.0",
"mocha": "^8.1.1",
"mocha": "^10.0.0",
"proxyquire": "^2.1.3",
"sinon": "^11.1.1"
"sinon": "^14.0.0"
},
"volta": {
"node": "16.17.0"
}
}
20 changes: 10 additions & 10 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('configuration', function() {
const commonTests = function(lazy) {
it('loads things in', function() {
const x = gulpLoadPlugins({
lazy: lazy,
lazy,
config: {
dependencies: {
'gulp-foo': '1.0.0',
Expand Down Expand Up @@ -106,7 +106,7 @@ const commonTests = function(lazy) {

it('can take a pattern override', function() {
const x = gulpLoadPlugins({
lazy: lazy,
lazy,
pattern: 'jack-*',
replaceString: 'jack-',
config: {
Expand All @@ -125,7 +125,7 @@ const commonTests = function(lazy) {

it('can extend the patterns', function() {
const x = gulpLoadPlugins({
lazy: lazy,
lazy,
config: {
dependencies: {
'jack-foo': '1.0.0',
Expand All @@ -144,7 +144,7 @@ const commonTests = function(lazy) {

it('allows camelizing to be turned off', function() {
const x = gulpLoadPlugins({
lazy: lazy,
lazy,
camelize: false,
config: {
dependencies: {
Expand All @@ -160,7 +160,7 @@ const commonTests = function(lazy) {

it('camelizes plugins name by default', function() {
const x = gulpLoadPlugins({
lazy: lazy,
lazy,
config: {
dependencies: {
'gulp-foo-bar': '*'
Expand All @@ -175,7 +175,7 @@ const commonTests = function(lazy) {

it('lets something be completely renamed', function() {
const x = gulpLoadPlugins({
lazy: lazy,
lazy,
config: { dependencies: { 'gulp-foo': '1.0.0' } },
rename: { 'gulp-foo': 'bar' }
});
Expand All @@ -187,7 +187,7 @@ const commonTests = function(lazy) {
const restore = capture(process.stdout);
try {
const x = gulpLoadPlugins({
lazy: lazy,
lazy,
DEBUG: true,
config: { dependencies: { 'gulp-foo': '*' } }
});
Expand All @@ -206,7 +206,7 @@ const commonTests = function(lazy) {

it('supports loading scopped package as a nested reference', function() {
const x = gulpLoadPlugins({
lazy: lazy,
lazy,
config: { dependencies: { '@myco/gulp-test-plugin': '1.0.0' } }
});

Expand All @@ -215,7 +215,7 @@ const commonTests = function(lazy) {

it('supports loading scopped package as a top-level reference', function() {
const x = gulpLoadPlugins({
lazy: lazy,
lazy,
maintainScope: false,
config: { dependencies: { '@myco/gulp-test-plugin': '1.0.0' } }
});
Expand Down Expand Up @@ -246,7 +246,7 @@ const commonTests = function(lazy) {

it('supports transforming', function() {
const x = gulpLoadPlugins({
lazy: lazy,
lazy,
config: { dependencies: { 'gulp-foo': '1.0.0' } },
postRequireTransforms: {
foo: function(foo) {
Expand Down
Loading

0 comments on commit 44773ae

Please sign in to comment.