Remove $1 in CodeMirror$1 for development

This commit is contained in:
Rob Garrison 2018-07-23 11:24:38 -05:00
parent eea72befb1
commit e2b754bad6
3 changed files with 43 additions and 29 deletions

View File

@ -43,6 +43,12 @@ function isFolder(fileOrFolder) {
return stat.isDirectory();
}
// Rename CodeMirror$1 -> CodeMirror for development purposes
function renameCodeMirrorVariable(filePath) {
const file = fs.readFileSync(filePath, 'utf8');
fs.writeFileSync(filePath, file.replace(/CodeMirror\$1/g, 'CodeMirror'));
}
function updateExisting(lib) {
const libRoot = `${root}/node_modules/`;
const vendorRoot = `${root}/vendor/`;
@ -54,8 +60,11 @@ function updateExisting(lib) {
const folderRoot = `${vendorRoot}${folder}`;
const entries = fs.readdirSync(folderRoot);
entries.forEach(entry => {
// Remove $1 from "CodeMirror$1" in codemirror.js
if (entry === 'codemirror.js') {
renameCodeMirrorVariable(`${folderRoot}/${entry}`);
} else if (entry !== 'README.md' && entry !== 'LICENSE') {
// Ignore README.md & LICENSE files
if (entry !== 'README.md' && entry !== 'LICENSE') {
const entryPath = `${folderRoot}/${entry}`;
try {
if (fs.existsSync(entryPath)) {

View File

@ -8,9 +8,12 @@ function createZip() {
const fileName = 'stylus.zip';
const exclude = [
'.*', // dot files/folders (glob, not regexp)
'node_modules',
'tools',
'vendor/codemirror/lib/**', // get unmodified copy from node_modules
'node_modules/**',
'tools/**',
'package.json',
'package-lock.json',
'yarn.lock',
'*.zip'
];
@ -34,7 +37,9 @@ function createZip() {
});
archive.pipe(file);
archive.glob(`!(${exclude.join('|')})`);
archive.glob('**', {ignore: exclude});
// Don't use modified codemirror.js (see "update-libraries.js")
archive.directory('node_modules/codemirror/lib', 'vendor/codemirror/lib');
archive.finalize();
});
}

View File

@ -6408,7 +6408,7 @@ Doc.prototype = createObj(BranchChunk.prototype, {
unlinkDoc: function(other) {
var this$1 = this;
if (other instanceof CodeMirror$1) { other = other.doc; }
if (other instanceof CodeMirror) { other = other.doc; }
if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {
var link = this$1.linked[i];
if (link.doc != other) { continue }
@ -7773,10 +7773,10 @@ function wrappingChanged(cm) {
// A CodeMirror instance represents an editor. This is the object
// that user code is usually dealing with.
function CodeMirror$1(place, options) {
function CodeMirror(place, options) {
var this$1 = this;
if (!(this instanceof CodeMirror$1)) { return new CodeMirror$1(place, options) }
if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }
this.options = options = options ? copyObj(options) : {};
// Determine effective options based on given values and defaults.
@ -7788,7 +7788,7 @@ function CodeMirror$1(place, options) {
else if (options.mode) { doc.modeOption = options.mode; }
this.doc = doc;
var input = new CodeMirror$1.inputStyles[options.inputStyle](this);
var input = new CodeMirror.inputStyles[options.inputStyle](this);
var display = this.display = new Display(place, doc, input);
display.wrapper.CodeMirror = this;
updateGutters(this);
@ -7845,9 +7845,9 @@ function CodeMirror$1(place, options) {
}
// The default configuration options.
CodeMirror$1.defaults = defaults;
CodeMirror.defaults = defaults;
// Functions to run when options are changed.
CodeMirror$1.optionHandlers = optionHandlers;
CodeMirror.optionHandlers = optionHandlers;
// Attach the necessary event handlers when initializing the editor
function registerEventHandlers(cm) {
@ -7958,7 +7958,7 @@ function registerEventHandlers(cm) {
}
var initHooks = [];
CodeMirror$1.defineInitHook = function (f) { return initHooks.push(f); };
CodeMirror.defineInitHook = function (f) { return initHooks.push(f); };
// Indent the given line. The how parameter can be "smart",
// "add"/null, "subtract", or "prev". When aggressive is false
@ -9592,7 +9592,7 @@ function fromTextArea(textarea, options) {
};
textarea.style.display = "none";
var cm = CodeMirror$1(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
options);
return cm
}
@ -9643,14 +9643,14 @@ function addLegacyProps(CodeMirror) {
// EDITOR CONSTRUCTOR
defineOptions(CodeMirror$1);
defineOptions(CodeMirror);
addEditorMethods(CodeMirror$1);
addEditorMethods(CodeMirror);
// Set up methods on CodeMirror's prototype to redirect to the editor's document.
var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
{ CodeMirror$1.prototype[prop] = (function(method) {
{ CodeMirror.prototype[prop] = (function(method) {
return function() {return method.apply(this.doc, arguments)}
})(Doc.prototype[prop]); } }
@ -9658,39 +9658,39 @@ eventMixin(Doc);
// INPUT HANDLING
CodeMirror$1.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
// MODE DEFINITION AND QUERYING
// Extra arguments are stored as the mode's dependencies, which is
// used by (legacy) mechanisms like loadmode.js to automatically
// load a mode. (Preferred mechanism is the require/define calls.)
CodeMirror$1.defineMode = function(name/*, mode, …*/) {
if (!CodeMirror$1.defaults.mode && name != "null") { CodeMirror$1.defaults.mode = name; }
CodeMirror.defineMode = function(name/*, mode, …*/) {
if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name; }
defineMode.apply(this, arguments);
};
CodeMirror$1.defineMIME = defineMIME;
CodeMirror.defineMIME = defineMIME;
// Minimal default mode.
CodeMirror$1.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); });
CodeMirror$1.defineMIME("text/plain", "null");
CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); });
CodeMirror.defineMIME("text/plain", "null");
// EXTENSIONS
CodeMirror$1.defineExtension = function (name, func) {
CodeMirror$1.prototype[name] = func;
CodeMirror.defineExtension = function (name, func) {
CodeMirror.prototype[name] = func;
};
CodeMirror$1.defineDocExtension = function (name, func) {
CodeMirror.defineDocExtension = function (name, func) {
Doc.prototype[name] = func;
};
CodeMirror$1.fromTextArea = fromTextArea;
CodeMirror.fromTextArea = fromTextArea;
addLegacyProps(CodeMirror$1);
addLegacyProps(CodeMirror);
CodeMirror$1.version = "5.39.2";
CodeMirror.version = "5.39.2";
return CodeMirror$1;
return CodeMirror;
})));