Skip to main content

ferrijs_std/utils/
ctx.rs

1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3use rquickjs::{Ctx, Result};
4
5pub trait CtxExt {
6    fn get_script_or_module_name(&self) -> Result<String>;
7}
8
9impl CtxExt for Ctx<'_> {
10    fn get_script_or_module_name(&self) -> Result<String> {
11        if let Some(name) = self.script_or_module_name(0) {
12            name.to_string()
13        } else {
14            Ok(String::from("."))
15        }
16    }
17}