File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
packages/gitmoji-changelog-cli/src Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ describe('generate changelog', () => {
6464 fs . writeFileSync ( pkg , JSON . stringify ( content ) )
6565
6666 const output = gitmojiChangelog ( )
67+ console . log ( output . toString ( 'utf8' ) )
6768
6869 expect ( output . toString ( 'utf8' ) ) . includes ( [ 'Cannot retrieve the version from your configuration' ] )
6970 } )
@@ -411,6 +412,19 @@ describe('generate changelog', () => {
411412 expect ( getChangelog ( ) ) . includes ( [ '1.0.0' , '1.2.0' ] )
412413 } )
413414
415+ it ( 'should work by passing release as argument without package.json or configuration file' , async ( ) => {
416+ const pkg = path . join ( testDir , 'package.json' )
417+ const { version, ...content } = JSON . parse ( fs . readFileSync ( pkg ) . toString ( 'utf8' ) )
418+ fs . writeFileSync ( pkg , JSON . stringify ( content ) )
419+
420+ await makeChanges ( 'file1' )
421+ await commit ( ':sparkles: Add some file' )
422+ const output = gitmojiChangelog ( '1.0.0' )
423+ console . log ( output . toString ( 'utf8' ) )
424+
425+ expect ( getChangelog ( ) ) . includes ( [ '1.0.0' ] )
426+ } )
427+
414428 it ( 'should display an error if requested version isn\'t semver' , async ( ) => {
415429 const output = gitmojiChangelog ( 'awesomeversion' )
416430
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ async function main(options = {}) {
5656 throw Error ( `Cannot retrieve configuration for preset ${ options . preset } .` )
5757 }
5858
59- if ( ! projectInfo . version ) {
59+ if ( ! projectInfo . version && options . release === 'from-package' ) {
6060 throw Error ( 'Cannot retrieve the version from your configuration. Check it or you can do "gitmoji-changelog <wanted version>".' )
6161 }
6262 } catch ( e ) {
You can’t perform that action at this time.
0 commit comments