mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-07 21:24:26 +02:00
move generic command handling to commands/index.js
This commit is contained in:
parent
c3e58b3063
commit
05cadae5d8
9 changed files with 492 additions and 449 deletions
|
@ -1,7 +1,7 @@
|
|||
var _ = require('underscore');
|
||||
var intl = require('../intl');
|
||||
|
||||
var GitCommands = require('../git/commands');
|
||||
var Commands = require('../commands');
|
||||
|
||||
var Errors = require('../util/errors');
|
||||
var GitError = Errors.GitError;
|
||||
|
@ -29,7 +29,7 @@ DisabledMap.prototype.getInstantCommands = function() {
|
|||
// XXX get hold of vcs from disabledMap
|
||||
var vcs = 'git';
|
||||
disabledCommand = disabledCommand.slice(vcs.length + 1);
|
||||
var gitRegex = GitCommands.commands.getRegexMap()[vcs][disabledCommand];
|
||||
var gitRegex = Commands.commands.getRegexMap()[vcs][disabledCommand];
|
||||
if (!gitRegex) {
|
||||
throw new Error('wuttttt this disbaled command' + disabledCommand +
|
||||
' has no regex matching');
|
||||
|
|
|
@ -16,7 +16,7 @@ var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
|
|||
var DisabledMap = require('../level/disabledMap').DisabledMap;
|
||||
var Command = require('../models/commandModel').Command;
|
||||
var GitShim = require('../git/gitShim').GitShim;
|
||||
var GitCommands = require('../git/commands');
|
||||
var Commands = require('../commands');
|
||||
|
||||
var MultiView = require('../views/multiView').MultiView;
|
||||
var CanvasTerminalHolder = require('../views').CanvasTerminalHolder;
|
||||
|
@ -309,7 +309,7 @@ var Level = Sandbox.extend({
|
|||
}
|
||||
|
||||
var matched = false;
|
||||
_.each(GitCommands.commands.getCommandsThatCount(), function(map) {
|
||||
_.each(Commands.commands.getCommandsThatCount(), function(map) {
|
||||
_.each(map, function(regex) {
|
||||
matched = matched || regex.test(command.get('rawStr'));
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var _ = require('underscore');
|
||||
|
||||
var GitCommands = require('../git/commands');
|
||||
var Commands = require('../commands');
|
||||
var SandboxCommands = require('../level/sandboxCommands');
|
||||
|
||||
// more or less a static class
|
||||
|
@ -8,7 +9,7 @@ var ParseWaterfall = function(options) {
|
|||
options = options || {};
|
||||
this.options = options;
|
||||
this.shortcutWaterfall = options.shortcutWaterfall || [
|
||||
GitCommands.commands.getShortcutMap()
|
||||
Commands.commands.getShortcutMap()
|
||||
];
|
||||
|
||||
this.instantWaterfall = options.instantWaterfall || [
|
||||
|
@ -22,14 +23,14 @@ var ParseWaterfall = function(options) {
|
|||
ParseWaterfall.prototype.initParseWaterfall = function() {
|
||||
// check for node when testing
|
||||
if (!require('../util').isBrowser()) {
|
||||
this.parseWaterfall = [GitCommands.parse];
|
||||
this.parseWaterfall = [Commands.parse];
|
||||
return;
|
||||
}
|
||||
|
||||
// by deferring the initialization here, we dont require()
|
||||
// level too early (which barfs our init)
|
||||
this.parseWaterfall = this.options.parseWaterfall || [
|
||||
GitCommands.parse,
|
||||
Commands.parse,
|
||||
SandboxCommands.parse,
|
||||
SandboxCommands.getOptimisticLevelParse(),
|
||||
SandboxCommands.getOptimisticLevelBuilderParse()
|
||||
|
|
|
@ -4,7 +4,7 @@ var util = require('../util');
|
|||
var constants = require('../util/constants');
|
||||
var intl = require('../intl');
|
||||
|
||||
var GitCommands = require('../git/commands');
|
||||
var Commands = require('../commands');
|
||||
var Errors = require('../util/errors');
|
||||
var CommandProcessError = Errors.CommandProcessError;
|
||||
var GitError = Errors.GitError;
|
||||
|
@ -124,7 +124,7 @@ var getAllCommands = function() {
|
|||
require('../level').regexMap,
|
||||
regexMap
|
||||
);
|
||||
_.each(GitCommands.commands.getRegexMap(), function(map, vcs) {
|
||||
_.each(Commands.commands.getRegexMap(), function(map, vcs) {
|
||||
_.each(map, function(regex, method) {
|
||||
allCommands[vcs + ' ' + method] = regex;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue