From 83f3063bbaa3c3e8993ea997ff33ba9d1c32081c Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Tue, 30 Jul 2019 17:00:08 +0900 Subject: [PATCH] dirname & filename --- README.md | 2 ++ desktop/sources/scripts/library.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index b232f6c..39914ab 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,8 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i - `(file ~path)` Returns the content of a file. - `(dirpath ~path)` Returns the path of a directory. - `(filepath ~path)` Returns the path of a file. +- `(dirname ~path)` Returns the name of a folder. +- `(filename ~path)` Returns the name of a file. - `(exit ~force)` Exits Ronin. - `(echo ...args)` Print arguments to interface. - `(debug arg)` Print arguments to console. diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index b2c891a..456c6a0 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -517,6 +517,10 @@ function Library (ronin) { return path } + this.dirname = (path = this.filepath()) => { // Returns the name of a folder. + return require('path').basename(require('path').dirname(path)) + } + this.filename = (path = this.filepath()) => { // Returns the name of a file. return require('path').parse(path).name }