Permalink
Browse files

Fix for issue #241 plus tidying

  • Loading branch information...
timdown committed Aug 22, 2014
1 parent 822d94b commit b2f493694d47bb806b0c1fea1b6ef11281b3fcab
Showing with 56 additions and 75 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 .idea/.name
  3. +1 −1 .idea/modules.xml
  4. 0 .idea/{rangy_github.iml → rangy.iml}
  5. +0 −41 bower.json
  6. +34 −11 builder/build.js
  7. +1 −1 package.json
  8. +17 −20 src/core/core.js
View
@@ -0,0 +1,2 @@
.idea
dist
View
@@ -1 +1 @@
rangy_github
rangy
View
@@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/rangy_github.iml" filepath="$PROJECT_DIR$/.idea/rangy_github.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/rangy.iml" filepath="$PROJECT_DIR$/.idea/rangy.iml" />
</modules>
</component>
</project>
File renamed without changes.
View
@@ -1,41 +0,0 @@
{
"name": "rangy-official",
"version": "1.3.0-alpha.20140822",
"homepage": "https://github.com/timdown/rangy",
"authors": [
"Tim Down <tim@timdown.co.uk>"
],
"description": "A cross-browser JavaScript range and selection library.",
"main": [
"lib/rangy-core.js",
"lib/rangy-classapplier.js",
"lib/rangy-highlighter.js",
"lib/rangy-selectionsaverestore.js",
"lib/rangy-serializer.js",
"lib/rangy-textrange.js"
],
"moduleType": [
"amd",
"globals",
"node"
],
"keywords": [
"range",
"selection",
"caret",
"DOM"
],
"license": "MIT",
"ignore": [
"roadmap.txt",
".idea",
"builder",
"dist",
"demos",
"external",
"fiddlings",
"spec",
"src",
"test"
]
}
View
@@ -26,8 +26,7 @@ var modules = [
"rangy-serializer.js",
"rangy-selectionsaverestore.js",
"rangy-textrange.js",
"rangy-highlighter.js"/*,
"rangy-util.js"*/
"rangy-highlighter.js"
];
var allScripts = [coreFilename].concat(modules);
@@ -51,7 +50,7 @@ function copyFileSync(srcFile, destFile, preserveTimestamps) {
}
}
function copyFilesRecursive(srcDir, destDir) {
function copyFiles(srcDir, destDir, recursive, fileNameTransformer) {
if (fs.existsSync(destDir)) {
if (!fs.statSync(destDir).isDirectory()) {
throw new Error("Destination exists and is not a directory");
@@ -68,19 +67,27 @@ function copyFilesRecursive(srcDir, destDir) {
var srcFileInfo = fs.lstatSync(srcFilePath);
if (srcFileInfo.isDirectory()) {
copyFilesRecursive(srcFilePath, destFilePath);
if (recursive) {
copyFiles(srcFilePath, destFilePath, true, fileNameTransformer);
}
} else if (srcFileInfo.isSymbolicLink()) {
throw new Error("Symbolic links are not supported");
} else {
if (fileNameTransformer) {
destFilePath = fileNameTransformer(destFilePath);
}
copyFileSync(srcFilePath, destFilePath);
}
});
}
function copyFilesRecursive(srcDir, destDir, fileNameTransformer) {
copyFiles(srcDir, destDir, true, fileNameTransformer);
}
function deleteBuildDir() {
// Delete the old build directory
if (fs.existsSync(buildDir)) {
var rimraf = require("rimraf");
rimraf(buildDir, function() {
console.log("Deleted old build directory");
callback();
@@ -111,10 +118,14 @@ function getVersion() {
console.log("Getting version from Git repo");
exec("git describe", function(error, stdout, stderr) {
console.log(error, stdout, stderr);
var result = /^.*-([\d]+)-.*$/.exec( stdout.trim() );
var commitNumber = parseInt(result[1]);
var now = new Date();
buildVersion = buildSpec.baseVersion + "." + [now.getFullYear(), ("" + (101 + now.getMonth())).slice(1), ("" + (100 + now.getDate())).slice(1)].join("");
//var result = /^.*-([\d]+)-.*$/.exec( stdout.trim() );
//var commitNumber = parseInt(result[1]);
//var now = new Date();
//buildVersion = buildSpec.baseVersion + "." + [now.getFullYear(), ("" + (101 + now.getMonth())).slice(1), ("" + (100 + now.getDate())).slice(1)].join("");
console.log("Getting version from package.json");
buildVersion = JSON.parse( fs.readFileSync("package.json")).version;
zipDir = buildDir + "rangy-" + buildVersion + "/";
fs.mkdirSync(zipDir);
uncompressedBuildDir = zipDir + "uncompressed/";
@@ -153,7 +164,7 @@ function copyModuleScripts() {
// Run build directives
moduleCode = moduleCode.replace(/\/\*\s?build:modularizeWithDependencies\((.*?)\)\s?\*\/([\s\S]*?)\/\*\s?build:modularizeEnd\s?\*\//gm, function(match, dependencies, code) {
var dependenciesArray = eval(dependencies);
//var dependenciesArray = eval(dependencies);
return [
'(function(factory, global) {',
' if (typeof define == "function" && define.amd) {',
@@ -360,6 +371,17 @@ function copyToLib() {
copyFilesRecursive(uncompressedBuildDir, "lib/");
}
function copyToRelease() {
var destDir = "../rangy-release/";
if (fs.existsSync(destDir)) {
copyFiles(zipDir, destDir, false, function(filePath) {
console.log(filePath.replace(/\.js$/, ".min.js"))
return filePath.replace(/\.js$/, ".min.js");
});
copyFiles(uncompressedBuildDir, destDir);
}
}
/*--------------------------------------------------------------------------------------------------------------------*/
// Start the build
@@ -378,7 +400,8 @@ var actions = [
minify,
zip,
tarGz,
copyToLib
copyToLib,
copyToRelease
];
View
@@ -1,7 +1,7 @@
{
"name": "rangy",
"description": "A cross-browser DOM range and selection library",
"version": "1.3.0-alpha.20140822",
"version": "1.3.0-alpha.20140822.2",
"author": {
"name": "Tim Down",
"email": "tim@timdown.co.uk",
View
@@ -434,8 +434,23 @@
/*----------------------------------------------------------------------------------------------------------------*/
// Wait for document to load before running tests
/* build:includeCoreModule(dom.js) */
/*----------------------------------------------------------------------------------------------------------------*/
/* build:includeCoreModule(domrange.js) */
/*----------------------------------------------------------------------------------------------------------------*/
/* build:includeCoreModule(wrappedrange.js) */
/*----------------------------------------------------------------------------------------------------------------*/
/* build:includeCoreModule(wrappedselection.js) */
/*----------------------------------------------------------------------------------------------------------------*/
// Wait for document to load before initializing
var docReady = false;
var loadHandler = function(e) {
@@ -449,7 +464,7 @@
};
if (isBrowser) {
// Test whether the document has already been loaded
// Test whether the document has already been loaded and initialize immediately if so
if (/^(?:complete|interactive)$/.test(document.readyState)) {
loadHandler();
} else {
@@ -462,23 +477,5 @@
}
}
/*----------------------------------------------------------------------------------------------------------------*/
/* build:includeCoreModule(dom.js) */
/*----------------------------------------------------------------------------------------------------------------*/
/* build:includeCoreModule(domrange.js) */
/*----------------------------------------------------------------------------------------------------------------*/
/* build:includeCoreModule(wrappedrange.js) */
/*----------------------------------------------------------------------------------------------------------------*/
/* build:includeCoreModule(wrappedselection.js) */
/*----------------------------------------------------------------------------------------------------------------*/
return api;
}, this);

0 comments on commit b2f4936

Please sign in to comment.