From f53289fe8f7f5d75cb107b2dcd5a3591da08c2fe Mon Sep 17 00:00:00 2001 From: Micha Mazaheri Date: Thu, 10 Sep 2015 21:54:53 +0200 Subject: [PATCH] Adapt to Paw JS API version 0.2.0 --- Cakefile | 8 +++++++- GoHTTPCodeGenerator.coffee | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cakefile b/Cakefile index 7da7390..4328927 100644 --- a/Cakefile +++ b/Cakefile @@ -29,8 +29,14 @@ build_copy = () -> fs.writeFileSync "#{ build_dir }/LICENSE", fs.readFileSync("./LICENSE") fs.writeFileSync "#{ build_dir }/go.mustache", fs.readFileSync("./go.mustache") fs.writeFileSync "#{ build_dir }/mustache.js", fs.readFileSync("./node_modules/mustache/mustache.js") - fs.writeFileSync "#{ build_dir }/URI.js", fs.readFileSync("./node_modules/URIjs/src/URI.min.js") + fs.writeFileSync "#{ build_dir }/URI.js", fs.readFileSync("./node_modules/URIjs/src/URI.js") + fs.writeFileSync "#{ build_dir }/punycode.js", fs.readFileSync("./node_modules/URIjs/src/punycode.js") + fs.writeFileSync "#{ build_dir }/IPv6.js", fs.readFileSync("./node_modules/URIjs/src/IPv6.js") + fs.writeFileSync "#{ build_dir }/SecondLevelDomains.js", fs.readFileSync("./node_modules/URIjs/src/SecondLevelDomains.js") + # legacy + fs.writeFileSync "#{ build_dir }/URI.min.js", fs.readFileSync("./node_modules/URIjs/src/URI.min.js") +# build: build CoffeeScript # build: build CoffeeScript and copy files to build directory build = (callback) -> # mkdir build dir diff --git a/GoHTTPCodeGenerator.coffee b/GoHTTPCodeGenerator.coffee index 744a15a..301fab2 100644 --- a/GoHTTPCodeGenerator.coffee +++ b/GoHTTPCodeGenerator.coffee @@ -1,5 +1,12 @@ -require "mustache.js" -require "URI.js" +# in API v0.2.0 and below (Paw 2.2.2 and below), require had no return value +((root) -> + if root.bundle?.minApiVersion('0.2.0') + root.URI = require("./URI") + root.Mustache = require("./mustache") + else + require("URI.min.js") + require("mustache.js") +)(this) addslashes = (str) -> ("#{str}").replace(/[\\"]/g, '\\$&')