/ / कस्टम संदेश भेजने की अनुमति देने के लिए gulp-git और gulp-प्रॉम्प्ट को लागू करने की कोशिश करना - जावास्क्रिप्ट, git, gulp

कस्टम प्रतिबद्ध संदेशों को अनुमति देने के लिए गल्प-गिट और गल्प-प्रॉम्प्ट को कार्यान्वित करने का प्रयास - जावास्क्रिप्ट, गिट, गल्प

प्रयास करते समय मुझे कई त्रुटियां हो रही हैंगलप-गिट को गल-प्रॉम्प्ट के साथ लागू करें। मैं उपयोगकर्ता को अपने स्वयं के अनूठे git प्रतिबद्ध संदेश को दर्ज करने की क्षमता देने की कोशिश कर रहा हूं, जब कमांड gulp टाइप करता है। उपयोगकर्ता को gulp-प्रतिबद्ध कमांड टाइप करने के बाद संदेश प्रदर्शित करना चाहिए।

यहाँ gulp कमांड है

//git commit task with gulp prompt
gulp.task("commit", function(){
var message;
gulp.src("./*", {buffer:false})
.pipe(prompt.prompt({
type: "input",
name: "commit",
message: "Please enter commit message..."
},  function(res){
message = res.commit;
}))
.pipe(git.commit(message));
});

वर्तमान में मुझे टर्मिनल में कमांड टाइप करने के बाद निम्नलिखित त्रुटियाँ मिल रही हैं।

TypeError: Cannot call method "indexOf" of undefined
at Object.module.exports [as commit] (/Users/me/Desktop/Example 4/node_modules/gulp-git/lib/commit.js:15:18)
at Gulp.gulp.task.gulp.src.pipe.git.add.args (/Users/me/Desktop/Example 4/gulpfile.js:190:15)
at module.exports (/Users/me/Desktop/Example 4/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/Users/me/Desktop/Example 4/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/Users/me/Desktop/Example 4/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/Users/me/Desktop/Example 4/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
at process._tickCallback (node.js:442:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:929:3

[?] Please enter commit message...

उत्तर:

जवाब के लिए 3 № 1

गल्प-प्रॉम्प्ट धाराओं के साथ अच्छी तरह से काम नहीं करता है, इसलिए गल्प-गिट (यहाँ: git.commit) को निष्पादित किया जाएगा message अभी भी undefined। इसलिए गुल-गिट ब्लॉक को गल-प्रॉम्प्ट के कॉलबैक के अंदर ले जाने की आवश्यकता है:

// git commit task with gulp prompt
gulp.task("commit", function(){
// just source anything here - we just wan"t to call the prompt for now
gulp.src("package.json")
.pipe(prompt.prompt({
type: "input",
name: "commit",
message: "Please enter commit message..."
},  function(res){
// now add all files that should be committed
// but make sure to exclude the .gitignored ones, since gulp-git tries to commit them, too
return gulp.src([ "!node_modules/", "./*" ], {buffer:false})
.pipe(git.commit(res.commit));
}));
});