Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function getChangedFilesForCommit( commitId ) {
const gitCommand = `git log -m -1 --name-only --pretty="format:" ${ commitId }`;
const changedFiles = tools.shExec( gitCommand, { verbosity: 'error' } ).trim();
// Merge commits can have two parents. Returned files for merge commits looks like:
// file1 <-- files from merged branch
// file2 <-- files from merged branch
// file <-- files from merged branch
//
// other-file1 <-- files from last commit before merge
// other-file2 <-- files from last commit before merge
// We need to filter out files from commit before merge.
return changedFiles.split( '\n\n' )[ 0 ].split( '\n' );
};
currentChangelog = currentChangelog.replace( changelogUtils.changelogHeader, '' );
// Concat header, new and current changelog.
let newChangelog = changelogUtils.changelogHeader + changelogEntries + '\n\n\n' + currentChangelog.trim();
newChangelog = newChangelog.trim() + '\n';
// Save the changelog.
changelogUtils.saveChangelog( newChangelog, repositoryPath );
log.info(
indent +
chalk.green( `Changelog for "${ chalk.underline( packageJson.name ) }" (v${ version }) has been generated.` )
);
// Commit the new changelog.
tools.shExec( `git add ${ changelogUtils.changelogFile }`, { verbosity: 'error' } );
tools.shExec( 'git commit -m "Docs: Changelog. [skip ci]"', { verbosity: 'error' } );
generatedChangelogMap.set( packageJson.name, version );
} );
} )
module.exports = function hasCommitsFromLastRelease() {
const shExecParams = { verbosity: 'error' };
let commitsNumber;
const tagsList = tools.shExec( 'git tag --list', shExecParams ).trim();
if ( tagsList.length ) {
commitsNumber = tools.shExec( 'git log `git describe --tags --abbrev=0`..HEAD --oneline | wc -l', shExecParams );
} else {
// Won't throw an error if repository does not have any commit.
commitsNumber = tools.shExec( 'git log --oneline 2> /dev/null | wc -l', shExecParams );
}
return parseInt( commitsNumber.trim() ) > 0;
};
fs.writeFile( tmpConfig.name, JSON.stringify( jsDocConfig ), 'utf8', error => {
if ( error ) {
return reject( error );
}
const cmd = require.resolve( 'jsdoc/jsdoc.js' );
console.log( 'JSDoc started...' );
try {
tools.shExec( `${ cmd } -c ${ tmpConfig.name }`, { verbosity: 'info' } );
} catch ( error ) {
return reject( `Error during JSDoc generation: ${ error.message }` );
}
console.log( `Documented ${ files.length } files!` );
resolve();
} );
} ) );
getLastTagFromGit() {
try {
const lastTag = tools.shExec( 'git describe --abbrev=0 --tags 2> /dev/null', { verbosity: 'error' } );
return lastTag.trim().replace( /^v/, '' ) || null;
} catch ( err ) {
return null;
}
},
function exec( command ) {
if ( dryRun ) {
log.info( `⚠️ ${ chalk.grey( 'Execute:' ) } "${ chalk.cyan( command ) }" in "${ chalk.grey.italic( process.cwd() ) }".` );
}
return tools.shExec( command, { verbosity: 'error' } );
}
function exec( command ) {
return tools.shExec( command, { verbosity: 'error' } );
}
function exec( command ) {
return tools.shExec( command, { verbosity: 'error' } );
}