diff --git a/Gruntfile.js b/Gruntfile.js index 25fcc3c3..8db4a1e9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,8 +12,11 @@ module.exports = function(grunt) { grunt.loadNpmTasks("grunt-git-describe"); // ---------- - var distribution = "build/openseadragon/openseadragon.js", + var packageJson = grunt.file.readJSON("package.json"), + distribution = "build/openseadragon/openseadragon.js", minified = "build/openseadragon/openseadragon.min.js", + packageDirName = "openseadragon-bin-" + packageJson.version, + packageDir = "build/" + packageDirName + "/", releaseRoot = "../site-build/built-openseadragon/", sources = [ "src/openseadragon.js", @@ -49,9 +52,10 @@ module.exports = function(grunt) { // ---------- // Project configuration. grunt.initConfig({ - pkg: grunt.file.readJSON("package.json"), + pkg: packageJson, clean: { build: ["build"], + "package": [packageDir], release: { src: [releaseRoot], options: { @@ -84,20 +88,20 @@ module.exports = function(grunt) { compress: { zip: { options: { - archive: "build/openseadragon.zip", + archive: "build/" + packageDirName + ".zip", level: 9 }, files: [ - { expand: true, cwd: "build/", src: ["openseadragon/**"] } + { expand: true, cwd: "build/", src: [ packageDirName + "/**" ] } ] }, tar: { options: { - archive: "build/openseadragon.tar.gz", + archive: "build/" + packageDirName + ".tar.gz", level: 9 }, files: [ - { expand: true, cwd: "build/", src: [ "openseadragon/**" ] } + { expand: true, cwd: "build/", src: [ packageDirName + "/**" ] } ] } }, @@ -152,6 +156,18 @@ module.exports = function(grunt) { grunt.file.copy("changelog.txt", "build/changelog.txt"); }); + // ---------- + // Copy:package task. + // Creates a directory tree to be compressed into a package. + grunt.registerTask("copy:package", function() { + grunt.file.recurse("build/openseadragon", function(abspath, rootdir, subdir, filename) { + var dest = packageDir + + (subdir ? subdir + "/" : '/') + + filename; + grunt.file.copy(abspath, dest); + }); + }); + // ---------- // Copy:release task. // Copies the contents of the build folder into the release folder. @@ -180,7 +196,7 @@ module.exports = function(grunt) { // ---------- // Package task. // Builds and creates the .zip and .tar.gz files. - grunt.registerTask("package", ["build", "compress"]); + grunt.registerTask("package", ["build", "copy:package", "compress", "clean:package"]); // ---------- // Publish task.