Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
911 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | Author Tobias Koppers @sokra
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | "use strict";
|
---|
| 7 |
|
---|
| 8 | module.exports = function getPaths(path) {
|
---|
| 9 | const parts = path.split(/(.*?[\\/]+)/);
|
---|
| 10 | const paths = [path];
|
---|
| 11 | const seqments = [parts[parts.length - 1]];
|
---|
| 12 | let part = parts[parts.length - 1];
|
---|
| 13 | path = path.substr(0, path.length - part.length - 1);
|
---|
| 14 | for (let i = parts.length - 2; i > 2; i -= 2) {
|
---|
| 15 | paths.push(path);
|
---|
| 16 | part = parts[i];
|
---|
| 17 | path = path.substr(0, path.length - part.length) || "/";
|
---|
| 18 | seqments.push(part.substr(0, part.length - 1));
|
---|
| 19 | }
|
---|
| 20 | part = parts[1];
|
---|
| 21 | seqments.push(part);
|
---|
| 22 | paths.push(part);
|
---|
| 23 | return {
|
---|
| 24 | paths: paths,
|
---|
| 25 | seqments: seqments
|
---|
| 26 | };
|
---|
| 27 | };
|
---|
| 28 |
|
---|
| 29 | module.exports.basename = function basename(path) {
|
---|
| 30 | const i = path.lastIndexOf("/"),
|
---|
| 31 | j = path.lastIndexOf("\\");
|
---|
| 32 | const p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
|
---|
| 33 | if (p < 0) return null;
|
---|
| 34 | const s = path.substr(p + 1);
|
---|
| 35 | return s;
|
---|
| 36 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.