static Scriptable getScope(String path) { if (useRequire) { // If CommonJS modules are enabled use a module scope that resolves // relative ids relative to the current URL, file or working directory. URI uri; if (path == null) { // use current directory for shell and -e switch uri = new File(System.getProperty("user.dir")).toURI(); } else { // find out whether this is a file path or a URL if (SourceReader.toUrl(path) != null) { try { uri = new URI(path); } catch (URISyntaxException x) { // fall back to file uri uri = new File(path).toURI(); } } else { uri = new File(path).toURI(); } } return new ModuleScope(global, uri, null); } else { return global; } }