| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -436,10 +436,13 @@ void BindingData::GetPackageScopeConfig( | |||
| 436 | 436 | } | |
| 437 | 437 | ||
| 438 | 438 | void EnableCompileCache(const FunctionCallbackInfo<Value>& args) { | |
| 439 | - CHECK(args[0]->IsString()); | ||
| 440 | 439 | Isolate* isolate = args.GetIsolate(); | |
| 441 | 440 | Local<Context> context = isolate->GetCurrentContext(); | |
| 442 | 441 | Environment* env = Environment::GetCurrent(context); | |
| 442 | + if (!args[0]->IsString()) { | ||
| 443 | + THROW_ERR_INVALID_ARG_TYPE(env, "cacheDir should be a string"); | ||
| 444 | + return; | ||
| 445 | + } | ||
| 443 | 446 | Utf8Value value(isolate, args[0]); | |
| 444 | 447 | CompileCacheEnableResult result = env->EnableCompileCache(*value); | |
| 445 | 448 | std::vector<Local<Value>> values = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,11 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // This tests module.enableCompileCache() throws when an invalid argument is passed. | ||
| 4 | + | ||
| 5 | + require('../common'); | ||
| 6 | + const { enableCompileCache } = require('module'); | ||
| 7 | + const assert = require('assert'); | ||
| 8 | + | ||
| 9 | + for (const invalid of [0, null, false, () => {}, {}, []]) { | ||
| 10 | + assert.throws(() => enableCompileCache(invalid), { code: 'ERR_INVALID_ARG_TYPE' }); | ||
| 11 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments