@acepad/here
v1.0.0
Published
Resolve file from import.meta.url in acepad/petit-node.
Downloads
8
Readme
NOTE: This package is supporsed to work in acepad, not a regular node envronment.
@acepad/here
Resolve import.meta.url in acepad/petit-node.
petit-node provides modules via BlobURL, @acepad/here determines original file from the BlobURL.
functions
filePath(bloburl:string)- Get file path correspond to
bloburl. bloburlnormally should beimport.meta.url
- Get file path correspond to
dirPath(bloburl:string)- Get directory path that points parent directory of
filePath(bloburl)
- Get directory path that points parent directory of
siblingPath(bloburl:string,relative_path:string)- Get file path that points
relative_pathfromdirPath(bloburl)
- Get file path that points
file(bloburl:string)- Get File object correspond to
bloburl. bloburlnormally should beimport.meta.url
- Get File object correspond to
dir(bloburl:string)- Get File object that points parent directory of
file(bloburl)
- Get File object that points parent directory of
sibling(bloburl:string,relative_path:string)- Get File object that points
relative_pathfromdir(bloburl)
- Get File object that points
(a stupid:-) Example
- Launch acepad.
- Press F2 (create new script)
- Type below, and press F5.
#!run
import {file} from "@acepad/here";
export function main(){
// get File object for this file itself.
const f=file(import.meta.url);
let x=0;// increases by pressing F5
const text_content=f.text();
const new_content=text_content.replace(/x=\d+/,`x=${x+1}`);
f.text(new_content);
}