Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the feature to update json2.js regulary from the upstream. #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendor/JSON-js"]
path = vendor/JSON-js
url = https://github.com/douglascrockford/JSON-js.git
14 changes: 14 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require "rake/testtask"
require "bundler/gem_tasks"
require 'fileutils'
require 'shellwords'

task :default => :test

Expand Down Expand Up @@ -65,3 +67,15 @@ task :test do
raise "test failures" if failed.any?
raise "all tests skipped" if !passed.any?
end

desc "Rebuild lib/execjs/support/json2.js"
task :js do
src = File.join('vendor', 'JSON-js', 'json2.js')
dest = File.join('lib', 'execjs', 'support', 'json2.js')
FileUtils.cp(src, dest)
patches = `#{['git', 'ls-files', 'patches', 'JSON-js'].shelljoin}`.split("\n")
patches.each do |patch|
`#{['patch', '-p1', '-i', patch].shelljoin}`
end
FileUtils.chmod(0644, dest)
end
Empty file added patches/JSON-js/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From f47c02c8536ce7cf0850b6a511fcecad6539eeaf Mon Sep 17 00:00:00 2001
From: Joshua Peek <[email protected]>
Date: Thu, 12 May 2011 10:24:07 -0500
Subject: [PATCH] Ensure JSON var isn't shadowed in JSC and Spidermonkey

---
lib/execjs/support/json2.js | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/execjs/support/json2.js b/lib/execjs/support/json2.js
index 36d3dc3..fb8fe0a 100644
--- a/lib/execjs/support/json2.js
+++ b/lib/execjs/support/json2.js
@@ -159,12 +159,13 @@
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.

-var JSON;
-if (!JSON) {
- JSON = {};
-}
+(function (global) {
+ if (!global.JSON) {
+ global.JSON = {};
+ }
+
+ var JSON = global.JSON;

-(function () {
"use strict";

function f(n) {
@@ -477,4 +478,4 @@ if (!JSON) {
throw new SyntaxError('JSON.parse');
};
}
-}());
+}(this));
--
2.5.5

1 change: 1 addition & 0 deletions vendor/JSON-js
Submodule JSON-js added at 633fe5