File tree Expand file tree Collapse file tree 3 files changed +92
-64
lines changed Expand file tree Collapse file tree 3 files changed +92
-64
lines changed Original file line number Diff line number Diff line change 5858 "@jxa/global-type" : " ^1.3.6" ,
5959 "@jxa/run" : " ^1.3.6" ,
6060 "@microsoft/eslint-formatter-sarif" : " ^3.0.0" ,
61- "@power-doctest/javascript" : " ^5.3.1 " ,
62- "@power-doctest/markdown" : " ^5.3.2 " ,
63- "@power-doctest/tester" : " ^5.3.2 " ,
61+ "@power-doctest/javascript" : " ^5.3.3 " ,
62+ "@power-doctest/markdown" : " ^5.3.3 " ,
63+ "@power-doctest/tester" : " ^5.3.3 " ,
6464 "@textlint-ja/textlint-rule-no-synonyms" : " ^1.3.0" ,
6565 "@textlint-rule/textlint-rule-require-header-id" : " ^1.0.1" ,
6666 "@textlint/regexp-string-matcher" : " ^2.0.2" ,
121121 "unist-util-find-before" : " ^2.0.5" ,
122122 "unist-util-parents" : " ^1.0.3" ,
123123 "unist-util-select" : " ^3.0.4" ,
124- "vm2" : " ^3.9.18" ,
125124 "wait-on" : " ^6.0.1" ,
126125 "workbox-cli" : " ^3.6.3"
127126 }
Original file line number Diff line number Diff line change 1- import { NodeVM } from "vm2 " ;
1+ import vm from "vm " ;
22import makeConsoleMock from "consolemock" ;
3+
34/**
45 * 次のコメントが実際に実行されないことをテストできるように変換する
56 *
@@ -75,14 +76,22 @@ export const toTestCode = (code) => {
7576 * @param {string } filePath
7677 */
7778export const runTestCode = ( code , filePath ) => {
78- // Run Test Code
79- const vm = new NodeVM ( {
80- require : {
81- external : true ,
82- context : {
83- console : ! ! process . env . ENABLE_CONSOLE ? console : makeConsoleMock ( )
84- }
85- }
79+ const script = vm . Script ( code , { filename : filePath } ) ;
80+ const HostBuildIns = Object . freeze ( {
81+ __proto__ : null ,
82+ version : parseInt ( process . versions . node . split ( "." ) [ 0 ] ) ,
83+ require,
84+ process,
85+ console,
86+ setTimeout,
87+ setInterval,
88+ setImmediate,
89+ clearTimeout,
90+ clearInterval,
91+ clearImmediate,
92+ } ) ;
93+ script . runInNewContext ( {
94+ ...HostBuildIns ,
95+ console : ! ! process . env . ENABLE_CONSOLE ? console : makeConsoleMock ( )
8696 } ) ;
87- vm . run ( code , filePath ) ;
8897} ;
You can’t perform that action at this time.
0 commit comments