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

Add support for directory creation to --output-file flag #5672

Merged
merged 1 commit into from Oct 29, 2021
Merged

Add support for directory creation to --output-file flag #5672

merged 1 commit into from Oct 29, 2021

Conversation

dreyks
Copy link
Contributor

@dreyks dreyks commented Oct 29, 2021

Which issue, if any, is this issue related to?

Closes #5670

Is there anything in the PR that needs further explanation?

Looks like the test-files that were a part of the original PR were removed in a big refactoring PR so I haven't added any

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dreyks Thanks for creating this patch quickly! Can you add a test case?

lib/writeOutputFile.js Outdated Show resolved Hide resolved
@ybiquitous
Copy link
Member

For example, it seems good to add simple test cases:

// lib/__tests__/writeOutputFile.test.js

'use strict';

const writeOutputFile = require('../writeOutputFile');

describe('writeOutputFile', () => {
	it('creates a file', () => {
		// ...
	});

	it('creates a directory if it does not exist', () => {
		// ...
	});
});

@dreyks
Copy link
Contributor Author

dreyks commented Oct 29, 2021

should this test write to the real FS or do we want to add memfs or similar?

@ybiquitous
Copy link
Member

Can you use the real FS?

@dreyks
Copy link
Contributor Author

dreyks commented Oct 29, 2021

i can. i'll just clean up tmp files after each test


expect((await fs.readFile(filePath)).toString()).toEqual('test content');

await fs.rmdir(path.dirname(filePath), { recursive: true });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks a bit concerning, maybe I should replace this with

await fs.unlink(filePath)
await fs.rmDir(path.dirname(filePath))

so that there's no way to accidentally remove more than we expect :)

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! LGTM 👍🏼

@dreyks
Copy link
Contributor Author

dreyks commented Oct 29, 2021

i think i still need a second approval to merge this. do I need to do anything else or is the process now on your (stylelint maintainers) side?

@jeddy3 jeddy3 changed the title autocreate --output-file directory Add support for directory creation to --output-file flag Oct 29, 2021
Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dreyks Thanks for the pull request. LGTM.

were removed in a big refactoring PR

Oops, removing them was probably a mistake by me...

do I need to do anything else or is the process now on your (stylelint maintainers) side?

It's on our side.

@jeddy3 jeddy3 merged commit c125093 into stylelint:main Oct 29, 2021
@jeddy3
Copy link
Member

jeddy3 commented Oct 29, 2021

Changelog entry added:

  • Added: support for directory creation to --output-file flag (#5672).

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

Successfully merging this pull request may close these issues.

Add support for directory creation to --output-file flag
3 participants