Skip to content

Instantly share code, notes, and snippets.

@ichernev
Created February 20, 2012 16:15
Show Gist options
  • Save ichernev/1869953 to your computer and use it in GitHub Desktop.
Save ichernev/1869953 to your computer and use it in GitHub Desktop.
sandboxed-module & coffee-script issue
#!/bin/bash
mkdir tmp; cd tmp
cat > sandbox.coffee <<EOF!
x = require 'foo'
exports.do = ->
console.log x.foo
EOF!
cat > test_sandbox.coffee <<EOF!
require 'coffee-script'
sandboxedModule = require 'sandboxed-module'
s = sandboxedModule.require './sandbox',
requires:
'foo':
foo: "Injected foo"
s.do()
EOF!
run() {
echo "$@"
"$@"
}
echo "make sure you have installed coffee-script and sandboxed-module"
npm install coffee-script # either install globally or put ./node_modules/.bin to PATH
npm install sandboxed-module
echo
echo "This fails on node v0.6.9"
rm -f sandbox.js
run coffee test_sandbox.coffee
echo
run coffee -c sandbox.coffee
echo "This should print 'Injected foo'"
run coffee test_sandbox.coffee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment