-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "otherPackage", | ||
"contributors": [{ "name": "Other Friend", "email": "[email protected]" }], | ||
"author": { "name": "George the Builder", "email": "[email protected]" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,7 @@ describe('Generate', () => { | |
`); | ||
}); | ||
|
||
it('should generate a CODEOWNERS FILE with package.maintainers field using cosmiconfig', async () => { | ||
it('should generate a CODEOWNERS FILE with package.contributors and package.author field using cosmiconfig', async () => { | ||
search.mockImplementationOnce(() => | ||
Promise.resolve({ | ||
isEmpty: false, | ||
|
@@ -137,15 +137,10 @@ describe('Generate', () => { | |
'dir2/dir1/package.json': '../__mocks__/package2.json', | ||
'dir6/package.json': '../__mocks__/package3.json', | ||
'dir7/package.json': '../__mocks__/package4.json', | ||
'dir8/package.json': '../__mocks__/package5.json', | ||
}; | ||
|
||
sync.mockReturnValueOnce([ | ||
...Object.keys(packageFiles), | ||
'dir5/package.json', | ||
'dir2/dir1/package.json', | ||
'dir6/package.json', | ||
'dir7/package.json', | ||
]); | ||
sync.mockReturnValueOnce(Object.keys(packageFiles)); | ||
|
||
sync.mockReturnValueOnce(['.gitignore']); | ||
const withAddedPackageFiles = { ...packageFiles, ...withGitIgnore }; | ||
|
@@ -165,6 +160,58 @@ describe('Generate', () => { | |
dir5/ [email protected] [email protected] | ||
# Rule extracted from dir2/dir1/package.json | ||
dir2/dir1/ [email protected] [email protected] | ||
# Rule extracted from dir8/package.json | ||
dir8/ [email protected] [email protected] | ||
# Rule extracted from dir1/CODEOWNERS | ||
dir1/*.ts @eeny @meeny | ||
# Rule extracted from dir1/CODEOWNERS | ||
dir1/README.md @miny | ||
# Rule extracted from dir2/CODEOWNERS | ||
dir2/*.ts @moe | ||
# Rule extracted from dir2/CODEOWNERS | ||
dir2/dir3/*.ts @miny | ||
# Rule extracted from dir2/dir3/CODEOWNERS | ||
dir2/dir3/*.ts @miny | ||
#################################### Generated content - do not edit! ####################################" | ||
`); | ||
}); | ||
it('should generate a CODEOWNERS FILE with package.maintainers field using cosmiconfig', async () => { | ||
search.mockImplementationOnce(() => | ||
Promise.resolve({ | ||
isEmpty: false, | ||
filepath: '/some/package.json', | ||
config: { | ||
output: 'CODEOWNERS', | ||
useMaintainers: true, | ||
}, | ||
}) | ||
); | ||
|
||
const packageFiles = { | ||
...files, | ||
'dir5/package.json': '../__mocks__/package1.json', | ||
'dir2/dir1/package.json': '../__mocks__/package2.json', | ||
'dir6/package.json': '../__mocks__/package3.json', | ||
'dir7/package.json': '../__mocks__/package4.json', | ||
}; | ||
|
||
sync.mockReturnValueOnce(Object.keys(packageFiles)); | ||
|
||
sync.mockReturnValueOnce(['.gitignore']); | ||
const withAddedPackageFiles = { ...packageFiles, ...withGitIgnore }; | ||
readFile.mockImplementation((file: keyof typeof withAddedPackageFiles, callback: Callback) => { | ||
const content = readFileSync(path.join(__dirname, withAddedPackageFiles[file])); | ||
callback(null, content); | ||
}); | ||
|
||
await generateCommand({ parent: {} }); | ||
expect(search).toHaveBeenCalled(); | ||
expect(writeFile.mock.calls[0][1]).toMatchInlineSnapshot(` | ||
"#################################### Generated content - do not edit! #################################### | ||
# This block has been generated with codeowners-generator (for more information https://github.com/gagoar/codeowners-generator/README.md) | ||
# To re-generate, run \`npm run codeowners-generator generate\`. Don't worry, the content outside this block will be kept. | ||
# Rule extracted from dir5/package.json | ||
dir5/ [email protected] [email protected] | ||
# Rule extracted from dir2/dir1/package.json | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters