From c84fc276e8e68ca43cf2cd1df9b90efc4797eecb Mon Sep 17 00:00:00 2001 From: Mickael Jeanroy Date: Wed, 23 Nov 2016 11:32:38 +0100 Subject: [PATCH] feat: display default messages without dependencies --- src/license-plugin.js | 2 +- test/license-plugin.spec.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/license-plugin.js b/src/license-plugin.js index acd22d27..b7bc78ed 100644 --- a/src/license-plugin.js +++ b/src/license-plugin.js @@ -204,7 +204,7 @@ class LicensePlugin { .trim() .value(); - fs.writeFileSync(output, text); + fs.writeFileSync(output, text || 'No third parties dependencies'); } } } diff --git a/test/license-plugin.spec.js b/test/license-plugin.spec.js index 13f30bd4..f0583984 100644 --- a/test/license-plugin.spec.js +++ b/test/license-plugin.spec.js @@ -604,6 +604,33 @@ describe('LicensePlugin', () => { }); }); + it('should display default message without dependencies', (done) => { + const file = path.join(tmpDir.name, 'third-party.txt'); + const instance = new LicensePlugin({ + thirdParty: { + output: file, + }, + }); + + instance._dependencies = {}; + + const result = instance.ongenerate(false); + + expect(result).not.toBeDefined(); + + fs.readFile(file, 'utf-8', (err, content) => { + if (err) { + done.fail(err); + return; + } + + const txt = content.toString(); + expect(txt).toBeDefined(); + expect(txt).toEqual('No third parties dependencies'); + done(); + }); + }); + it('should not display private dependencies by default', (done) => { const file = path.join(tmpDir.name, 'third-party.txt'); const instance = new LicensePlugin({