Skip to content

Conversation

@adamwathan
Copy link
Member

Resolves #147.

When enforcing our lint rules, a subtle bug was introduced where paths were being resolved to the root of the file system instead of relative to where the CLI source file was located.

This is because of the leading slash in the second argument to path.resolve:

path.resolve(__dirname, '/../package.json')

Originally this was written as:

path.resolve(__dirname + '/../package.json')

...which worked fine, but failed ESLint. Swapping the + for a , caused path.resolve to treat the second path as absolute and resolve to just that path on it's own.

This change gets rid of the leading slash so the path is properly resolved as relative to __dirname.

This change also stops the CLI from loading the user's config file before passing it in for processing. Previously we supported passing a config object rather than just a path, but when removing that option, we made the mistake of not updating the CLI tool to pass a path instead of an object.

@adamwathan adamwathan merged commit 1d1e96d into master Nov 8, 2017
@adamwathan adamwathan deleted the fix-path-issues branch November 10, 2017 13:18
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 this pull request may close these issues.

CLI with config file "TypeError: Path must be a string. Received { colors: ... "

2 participants