File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
packages/shipjs/src/step/prepare Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1+ const path = require ( 'path' ) ;
2+ import { prepareParams } from '../updateChangelog' ;
3+ import { parseArgs } from '../../../util' ;
4+ import tempWrite from 'temp-write' ;
5+
6+ describe ( 'prepareParams' , ( ) => {
7+ it ( 'loads configuration from --config option' , ( ) => {
8+ parseArgs . mockImplementation ( jest . requireActual ( '../../../util' ) . parseArgs ) ;
9+ const config = {
10+ writerOpts : {
11+ headerPartial : '## {{version}}' ,
12+ } ,
13+ } ;
14+ const configString = `module.exports = ${ JSON . stringify ( config ) } ;` ;
15+ const configPath = tempWrite . sync ( configString ) ;
16+ const configDir = path . basename ( path . dirname ( configPath ) ) ;
17+
18+ const { args } = prepareParams ( {
19+ dir : configDir ,
20+ conventionalChangelogArgs : `-i CHANGELOG.md -s --config ${ configPath } ` ,
21+ revisionRange : '1.0.0..1.0.1' ,
22+ reject : ( ) => { } ,
23+ } ) ;
24+ expect ( args . config ) . toEqual ( config ) ;
25+ } ) ;
26+ } ) ;
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ const argSpec = {
7878 '-t' : '--tag-prefix' ,
7979} ;
8080
81- function prepareParams ( {
81+ export function prepareParams ( {
8282 dir,
8383 conventionalChangelogArgs,
8484 releaseCount,
@@ -118,6 +118,9 @@ function prepareParams({
118118 }
119119 const templateContext =
120120 args . context && require ( path . resolve ( dir , args . context ) ) ;
121+ if ( args . config ) {
122+ args . config = require ( path . resolve ( dir , args . config ) ) ;
123+ }
121124 return { args, gitRawCommitsOpts, templateContext } ;
122125}
123126
You can’t perform that action at this time.
0 commit comments