Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Little sandbox for Node.js

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 src
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .npmignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Cakefile
Octocat-spinner-32 README.md
Octocat-spinner-32 package.json
README.md

build status

Dune

An easy to use VM for loading and running scripts.

You pass it code, it returns back its module.exports

Install

npm install dune

API

file() = (full_path_to_file, optional_context, custom_require) ->

var assert = require('assert');
var path = require('path');

var exports = dune.file(path.join(__dirname, 'myfile.js'));

assert.equal(exports, 'hello');

myfile.js

module.exports = 'hello';

string() = (code_to_run, path_to_code, context, custom_require) ->

var assert = require('assert');

var exports = dune.string('module.exports = "hello"');

assert.equal(exports, 'hello');

NOTE! If using node's require() in your code, you will need to pass in the full path where the code would theoretically be present at. Example:

var assert = require('assert');
var path = require('path');

var exports = dune.string(
  'module.exports = require("./myfile.js")',
  path.join(__dirname, 'test.vm')
);

assert.equal(exports, 'hello');

License

MIT-LICENSE

Something went wrong with that request. Please try again.