Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function commitTask(task: CommitTaskDesc): void {
dbg('running commitizen commit');
// use this to get the resolved path to the root of the commitizen directory
const cliPath = require
.resolve('commitizen/package.json')
.replace('package.json', '');
return czBootstrap(
{
cliPath,
config: {
path: task.path,
},
},
// this gets the arguments in the right positions to
// satisfy commitizen, which strips the first two
// (assumes that they're `['node', 'git-cz']`)
[null, ...task.restOptions],
);
}
/* tslint:disable no-any */
/**
* https://github.com/commitizen/cz-conventional-changelog
*/
import engine from "./engine";
import { Options } from "./types";
import { configLoader } from "commitizen";
/**
* @todo Remove and replace with our own version
*/
import conventionalCommitTypes from "conventional-commit-types";
const config = configLoader.load();
const defaultOptions: Options = {
defaultBody: process.env.CZ_BODY || config.defaultBody,
defaultSubject: process.env.CZ_SUBJECT || config.defaultSubject,
defaultType: process.env.CZ_TYPE || config.defaultType,
maxHeaderWidth:
(process.env.CZ_MAX_HEADER_WIDTH &&
parseInt(process.env.CZ_MAX_HEADER_WIDTH, 10)) ||
config.maxHeaderWidth ||
100,
maxLineWidth:
(process.env.CZ_MAX_LINE_WIDTH &&
parseInt(process.env.CZ_MAX_LINE_WIDTH, 10)) ||
config.maxLineWidth ||
100,
types: conventionalCommitTypes.types,
};
async function initCommit() {
const {hasFiles: hasStagedFiles} = await getDiffedFiles({checkIfStaged: true})
if (hasStagedFiles === false) {
console.log('No files added to staging! Did you forget to run git add?\n')
const modified = await getDiffedFiles()
if (modified.hasFiles) {
console.log('Showing the files that you could add:')
console.log(modified.files)
}
return
}
bootstrap({
debug: false,
cliPath: path.join(process.cwd(), 'node_modules/commitizen'),
config: {
path: require.resolve('@s-ui/cz')
}
})
}