From 0160c88dd09927e2cdd21e430b651389b634bfbb Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 25 Aug 2022 00:49:10 +0200 Subject: [PATCH] unet-cli: use modern module imports Instead of loading the entire `fs` module space using `require()`, utilize the `import` statement to load the fs function we actually use. Signed-off-by: Jo-Philipp Wich --- scripts/unet-cli | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/unet-cli b/scripts/unet-cli index 883f1ba..96894a3 100755 --- a/scripts/unet-cli +++ b/scripts/unet-cli @@ -1,6 +1,6 @@ #!/usr/bin/env ucode -let fs = require("fs"); +import { access, basename, dirname, mkstemp, open, writefile } from 'fs'; function assert(cond, message) { if (!cond) { @@ -12,9 +12,9 @@ function assert(cond, message) { } let script_dir = sourcepath(0, true); -if (fs.basename(script_dir) == "scripts") { - unet_tool = `${fs.dirname(script_dir)}/unet-tool`; - assert(fs.access(unet_tool, "x"), "unet-tool missing"); +if (basename(script_dir) == "scripts") { + unet_tool = `${dirname(script_dir)}/unet-tool`; + assert(access(unet_tool, "x"), "unet-tool missing"); } else { unet_tool = "unet-tool"; } @@ -28,7 +28,7 @@ defaults = { }; const usage_message = ` -Usage: ${fs.basename(sourcepath())} [] [] [