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

fix: archive whitelist to support custom name #107

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = async (root, pkg, release, customName) => {

const serviceFile = generateServiceFile(root, customPackage);
const specFile = generateSpecFile(specsDirectory, customPackage, release);
const archiveWhitelist = getArchiveWhitelist(pkg);
const archiveWhitelist = getArchiveWhitelist(customPackage);

await archiver.compress(root, sourcesArchive, archiveWhitelist);

Expand Down
47 changes: 46 additions & 1 deletion test/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ describe('generate', () => {
);
});

it('creates the spec file with a custom name if specified with white list', async () => {
await generate('/path/to/project', pkgWithWhitelist, 1, 'penguin');
sandbox.assert.calledWith(
fs.writeFileSync,
'/path/to/project/SPECS/penguin.spec',
sandbox.match('%define name penguin')
);
});

it('creates the sources archive with a custom name if specified', async () => {
await generate('/path/to/project', pkg, null, 'penguin');
sandbox.assert.calledWith(
Expand All @@ -112,7 +121,25 @@ describe('generate', () => {
{
files: undefined,
main: 'index.js',
service: 'my-cool-api.service'
service: 'penguin.service'
}
);
});

it('creates the sources archive with a custom name if specified with white list', async () => {
await generate('/path/to/project', pkgWithWhitelist, null, 'penguin');
sandbox.assert.calledWith(
archiver.compress,
'/path/to/project',
'/path/to/project/SOURCES/penguin.tar.gz',
{
main: 'server.js',
files: [
'lib',
'routes',
'index.js'
],
service: 'penguin.service'
}
);
});
Expand Down Expand Up @@ -144,6 +171,15 @@ describe('generate', () => {
);
});

it('creates the service file with a custom name if specified with white list', async () => {
await generate('/path/to/project', pkgWithWhitelist, 1, 'penguin');
sandbox.assert.calledWith(
fs.writeFileSync,
'/path/to/project/penguin.service',
sandbox.match('SyslogIdentifier=penguin')
);
});

it('creates the sources archive with a custom name if specified', async () => {
await generate('/path/to/project', pkg, null, 'penguin');
sandbox.assert.calledWith(
Expand All @@ -153,6 +189,15 @@ describe('generate', () => {
);
});

it('creates the sources archive with a custom name if specified with white list', async () => {
await generate('/path/to/project', pkgWithWhitelist, null, 'penguin');
sandbox.assert.calledWith(
archiver.compress,
'/path/to/project',
'/path/to/project/SOURCES/penguin.tar.gz'
);
});

it('returns an array of files created', async () => {
const filesExpected = ['SPECS/my-cool-api.spec', 'SOURCES/my-cool-api.tar.gz', 'my-cool-api.service'];
const files = await generate('/path/to/project', pkg, null, null);
Expand Down