dirname & filename

This commit is contained in:
Devine Lu Linvega 2019-07-30 17:00:08 +09:00
parent 7dcebb8865
commit 83f3063bba
2 changed files with 6 additions and 0 deletions

View File

@ -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.

View File

@ -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
}