(https://github.com/jimthedev)",
"license": "MIT",
"devDependencies": {
- "@babel/cli": "7.11.6",
- "@babel/core": "7.11.6",
- "@babel/plugin-proposal-object-rest-spread": "7.11.0",
- "@babel/preset-env": "7.11.5",
- "@babel/register": "7.11.5",
- "@istanbuljs/nyc-config-babel": "2.1.1",
- "axios": "0.19.0",
- "babel-plugin-istanbul": "5.2.0",
- "chai": "4.1.2",
- "codecov.io": "0.1.6",
- "conventional-changelog-conventionalcommits": "4.4.0",
+ "@babel/cli": "7.17.10",
+ "@babel/core": "7.18.0",
+ "@babel/plugin-proposal-object-rest-spread": "7.18.0",
+ "@babel/preset-env": "7.18.0",
+ "@babel/register": "7.17.7",
+ "@istanbuljs/nyc-config-babel": "3.0.0",
+ "babel-plugin-istanbul": "6.1.1",
+ "chai": "4.3.6",
+ "codecov": "3.8.3",
+ "conventional-changelog-conventionalcommits": "4.6.3",
"cz-conventional-changelog-default-export": "0.0.0-semantically-released.1",
"ghooks": "2.0.4",
- "in-publish": "2.0.0",
- "mocha": "6.2.0",
- "mocha-junit-reporter": "1.18.0",
- "mocha-multi-reporters": "1.1.7",
- "nodemon": "1.19.1",
+ "in-publish": "2.0.1",
+ "mocha": "9.2.2",
+ "mocha-junit-reporter": "1.23.3",
+ "mocha-multi-reporters": "1.5.1",
+ "nodemon": "2.0.16",
"nyc": "15.1.0",
- "proxyquire": "2.1.0",
- "semantic-release": "15.14.0",
- "semver": "6.3.0",
- "sinon": "6.3.4",
- "uuid": "3.4.0"
+ "proxyquire": "2.1.3",
+ "semantic-release": "18.0.1",
+ "semver": "7.3.7",
+ "sinon": "12.0.1",
+ "uuid": "8.3.2"
},
"dependencies": {
- "cachedir": "2.2.0",
- "cz-conventional-changelog": "3.2.0",
+ "cachedir": "2.3.0",
+ "cz-conventional-changelog": "3.3.0",
"dedent": "0.7.0",
- "detect-indent": "6.0.0",
+ "detect-indent": "6.1.0",
"find-node-modules": "^2.1.2",
"find-root": "1.1.0",
- "fs-extra": "8.1.0",
- "glob": "7.1.4",
- "inquirer": "6.5.2",
+ "fs-extra": "9.1.0",
+ "glob": "7.2.3",
+ "inquirer": "8.2.4",
"is-utf8": "^0.2.1",
- "lodash": "^4.17.20",
- "minimist": "1.2.5",
+ "lodash": "4.17.21",
+ "minimist": "1.2.6",
"strip-bom": "4.0.0",
- "strip-json-comments": "3.0.1"
+ "strip-json-comments": "3.1.1"
},
"nyc": {
"extends": "@istanbuljs/nyc-config-babel",
@@ -98,7 +97,7 @@
},
"engineStrict": true,
"engines": {
- "node": ">= 10"
+ "node": ">= 12"
},
"collective": {
"type": "opencollective",
diff --git a/src/cli/strategies/git-cz.js b/src/cli/strategies/git-cz.js
index dad0ebf1..059c5f33 100644
--- a/src/cli/strategies/git-cz.js
+++ b/src/cli/strategies/git-cz.js
@@ -41,6 +41,7 @@ function gitCz (rawGitArgs, environment, adapterConfig) {
let resolvedAdapterConfigPath = resolveAdapterPath(adapterConfig.path);
let resolvedAdapterRootPath = findRoot(resolvedAdapterConfigPath);
let prompter = getPrompter(adapterConfig.path);
+ let shouldStageAllFiles = rawGitArgs.includes('-a') || rawGitArgs.includes('--all');
isClean(process.cwd(), function (error, stagingIsClean) {
if (error) {
@@ -67,6 +68,6 @@ function gitCz (rawGitArgs, environment, adapterConfig) {
throw error;
}
});
- });
+ }, shouldStageAllFiles);
}
diff --git a/src/commitizen/staging.js b/src/commitizen/staging.js
index c485b5dd..c8a81c29 100644
--- a/src/commitizen/staging.js
+++ b/src/commitizen/staging.js
@@ -5,8 +5,8 @@ export { isClean };
/**
* Asynchrounously determines if the staging area is clean
*/
-function isClean (repoPath, done) {
- exec('git diff --no-ext-diff --name-only && git diff --no-ext-diff --cached --name-only', {
+function isClean (repoPath, done, stageAllFiles) {
+ exec(`git diff --cached --no-ext-diff --name-only ${!!stageAllFiles ? '&& git diff --no-ext-diff --name-only' : ''}`, {
maxBuffer: Infinity,
cwd: repoPath
}, function (error, stdout) {
diff --git a/src/common/util.js b/src/common/util.js
index 8f3f1cd3..a9e59e3f 100644
--- a/src/common/util.js
+++ b/src/common/util.js
@@ -38,7 +38,8 @@ function isFunction (functionToCheck) {
return false;
} else {
var getType = {};
- return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
+ var functionType = getType.toString.call(functionToCheck);
+ return functionToCheck && (functionType === '[object Function]' || functionType === '[object AsyncFunction]');
}
}
diff --git a/test/tests/commit.js b/test/tests/commit.js
index f9c7fa86..8048d657 100644
--- a/test/tests/commit.js
+++ b/test/tests/commit.js
@@ -311,6 +311,73 @@ ${(os.platform === 'win32') ? '' : ' '}
done();
});
});
+
+ it('should throw error if staging area is empty', function (done) {
+
+ this.timeout(config.maxTimeout); // this could take a while
+
+ // SETUP
+
+ let dummyCommitMessage = `one does not simply ignore the tests`;
+
+ // Describe a repo and some files to add and commit
+ let repoConfig = {
+ path: config.paths.endUserRepo,
+ files: {
+ dummyfile: {
+ contents: `duck-duck-gray-duck`,
+ filename: `mydummiestfile.txt`,
+ },
+ gitignore: {
+ contents: `node_modules/`,
+ filename: `.gitignore`,
+ }
+ }
+ };
+
+ // Describe an adapter
+ let adapterConfig = {
+ path: path.join(repoConfig.path, '/node_modules/cz-jira-smart-commit'),
+ npmName: 'cz-jira-smart-commit'
+ };
+
+ // Quick setup the repos, adapter, and grab a simple prompter
+ let prompter = quickPrompterSetup(repoConfig, adapterConfig, dummyCommitMessage);
+ // TEST
+
+ // Make an initial commit
+ commitizenCommit(inquirer, repoConfig.path, prompter, { disableAppendPaths: true, quiet: true, emitData: true }, function (error) {
+ // Should pass, as the files are added to the staging area
+ expect(error).to.be.null;
+
+ log(repoConfig.path, function (logOutput) {
+ expect(logOutput).to.have.string(dummyCommitMessage);
+ });
+ whatChanged(repoConfig.path, function (whatChangedOutput) {
+ expect(whatChangedOutput).to.have.string('A\t' + repoConfig.files.dummyfile.filename);
+
+ // Make changes and don't add them to the staging area
+ writeFilesToPath({
+ dummymodified: {
+ contents: repoConfig.files.dummyfile.contents + '-modified',
+ filename: repoConfig.files.dummyfile.filename,
+ add: false,
+ }
+ }, repoConfig.path);
+ // Define a dummy prompter
+ let prompter = function (cz, commit) {
+ commit(`${dummyCommitMessage} #2`, {});
+ };
+
+ commitizenCommit(inquirer, repoConfig.path, prompter, { disableAppendPaths: true, quiet: true, emitData: true }, function (error) {
+ // Should fail, as staging are is empty
+ expect(error).to.be.instanceOf(Error);
+ done();
+ });
+ });
+ });
+
+ });
});
afterEach(function () {
diff --git a/test/tests/staging.js b/test/tests/staging.js
index 02e8c4fd..2ff77256 100644
--- a/test/tests/staging.js
+++ b/test/tests/staging.js
@@ -78,6 +78,43 @@ describe('staging', function () {
});
});
+ it('should determine if --all flag adds files to staging area', function (done) {
+
+ this.timeout(config.maxTimeout); // this could take a while
+
+ // SETUP
+
+ // Describe a repo and some files to add and commit
+ let repoConfig = {
+ path: config.paths.endUserRepo,
+ files: {
+ dummyfile: {
+ contents: `duck-duck-gray-duck`,
+ filename: `mydummiestfile.txt`,
+ },
+ gitignore: {
+ contents: `node_modules/`,
+ filename: `.gitignore`
+ }
+ }
+ };
+
+ gitInit(repoConfig.path);
+
+ staging.isClean(repoConfig.path, function (stagingIsCleanError, stagingIsClean) {
+ expect(stagingIsCleanError).to.be.null;
+ expect(stagingIsClean).to.be.true;
+
+ writeFilesToPath(repoConfig.files, repoConfig.path);
+
+ staging.isClean(repoConfig.path, function (afterWriteStagingIsCleanError, afterWriteStagingIsClean) {
+ expect(afterWriteStagingIsCleanError).to.be.null;
+ expect(afterWriteStagingIsClean).to.be.true;
+
+ done();
+ });
+ }, true);
+ });
});
afterEach(function () {
diff --git a/test/tools/clean.js b/test/tools/clean.js
index d8d39439..47476161 100644
--- a/test/tools/clean.js
+++ b/test/tools/clean.js
@@ -1,6 +1,6 @@
import * as path from 'path';
import fs from 'fs-extra';
-import uuidv4 from 'uuid/v4';
+import { v4 as uuidv4} from 'uuid';
export {
before,
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy