From: Jo-Philipp Wich Date: Wed, 24 Aug 2022 22:49:10 +0000 (+0200) Subject: unet-cli: use modern module imports X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0160c88dd09927e2cdd21e430b651389b634bfbb;p=project%2Funetd.git 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 --- 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())} [] [] [