diff --git a/lib/generate.js b/lib/generate.js index 72f0939..2a9c398 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -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); diff --git a/test/generate.js b/test/generate.js index 3d3f5d3..7e9c6ad 100644 --- a/test/generate.js +++ b/test/generate.js @@ -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( @@ -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' } ); }); @@ -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( @@ -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);