|
20 | 20 | from .process import Process |
21 | 21 | from .sandboxjs import (JavascriptException, code_fragment_to_js, |
22 | 22 | exec_js_process, execjs) |
23 | | -from .utils import get_data |
| 23 | +from pkg_resources import resource_stream |
24 | 24 |
|
25 | 25 | _logger = logging.getLogger("cwltool") |
26 | 26 |
|
@@ -84,16 +84,14 @@ def jshint_js(js_text, globals=None, options=None): |
84 | 84 | "esversion": 5 |
85 | 85 | } |
86 | 86 |
|
87 | | - linter_folder = get_data("cwltool/jshint") |
88 | | - |
89 | | - with open(path.join(linter_folder, "jshint.js"), 'r', encoding='utf-8') as file: |
| 87 | + with resource_stream(__name__, "jshint/jshint.js") as file: |
90 | 88 | # NOTE: we need a global variable for lodash (which jshint depends on) |
91 | | - jshint_functions_text = "var global = this;" + file.read() |
| 89 | + jshint_functions_text = "var global = this;" + file.read().decode('utf-8') |
92 | 90 |
|
93 | | - with open(path.join(linter_folder, "jshint_wrapper.js"), "r", encoding='utf-8') as file: |
| 91 | + with resource_stream(__name__, "jshint/jshint_wrapper.js") as file: |
94 | 92 | # NOTE: we need to assign to ob, as the expression {validateJS: validateJS} as an expression |
95 | 93 | # is interpreted as a block with a label `validateJS` |
96 | | - jshint_functions_text += "\n" + file.read() + "\nvar ob = {validateJS: validateJS}; ob" |
| 94 | + jshint_functions_text += "\n" + file.read().decode('utf-8') + "\nvar ob = {validateJS: validateJS}; ob" |
97 | 95 |
|
98 | 96 | returncode, stdout, stderr = exec_js_process( |
99 | 97 | "validateJS(%s)" % json.dumps({ |
|
0 commit comments