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

Atom Deprecation Cop warning - Argument to path.dirname must be a string #14

Closed
jacekk015 opened this issue Oct 17, 2019 · 1 comment · Fixed by #19
Closed

Atom Deprecation Cop warning - Argument to path.dirname must be a string #14

jacekk015 opened this issue Oct 17, 2019 · 1 comment · Fixed by #19

Comments

@jacekk015
Copy link

Atom Deprecation Cop warning:

Deprecated calls
atom core (1 deprecation)
Argument to path.dirname must be a string

Object.dirname - /usr/share/atom/resources/app.asar/src/electron-shims.js:9:10
module.exports.moduleId - /home/jk/.atom/packages/atom-standard-formatter/node_modules/import-fresh/index.js:11:36
loadJSConfigFile - /home/jk/.atom/packages/atom-standard-formatter/node_modules/standard/node_modules/eslint/lib/cli-engine/config-array-factory.js:189:16
loadConfigFile - /home/jk/.atom/packages/atom-standard-formatter/node_modules/standard/node_modules/eslint/lib/cli-engine/config-array-factory.js:251:20
ConfigArrayFactory._loadConfigData - /home/jk/.atom/packages/atom-standard-formatter/node_modules/standard/node_modules/eslint/lib/cli-engine/config-array-factory.js:415:13
ConfigArrayFactory._loadExtendedShareableConfig - /home/jk/.atom/packages/atom-standard-formatter/node_modules/standard/node_modules/eslint/lib/cli-engine/config-array-factory.js:718:21
'use strict';
const path = require('path');
const resolveFrom = require('resolve-from');
const parentModule = require('parent-module');

module.exports = moduleId => {
	if (typeof moduleId !== 'string') {
		throw new TypeError('Expected a string');
	}

	const filePath = resolveFrom(path.dirname(parentModule(__filename)), moduleId);

	// Delete itself from module parent
	if (require.cache[filePath] && require.cache[filePath].parent) {
		let i = require.cache[filePath].parent.children.length;

		while (i--) {
			if (require.cache[filePath].parent.children[i].id === filePath) {
				require.cache[filePath].parent.children.splice(i, 1);
			}
		}
	}

	// Delete module from cache
	delete require.cache[filePath];

	// Return fresh module
	return require(filePath);
};
@meyfa
Copy link

meyfa commented Oct 8, 2020

This happens for me, too. I suspect parentModule is returning undefined in some circumstances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants