Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var path = require('path'),
|
---|
| 4 | fs = require('fs');
|
---|
| 5 |
|
---|
| 6 | /**
|
---|
| 7 | * Codec for absolute paths.
|
---|
| 8 | * @type {{name:string, decode: function, encode: function, root: function}}
|
---|
| 9 | */
|
---|
| 10 | module.exports = {
|
---|
| 11 | name : 'absolute',
|
---|
| 12 | decode: decode,
|
---|
| 13 | encode: encode,
|
---|
| 14 | root : root
|
---|
| 15 | };
|
---|
| 16 |
|
---|
| 17 | /**
|
---|
| 18 | * Decode the given uri.
|
---|
| 19 | * Any path with leading slash is tested in an absolute sense.
|
---|
| 20 | * @this {{options: object}} A loader or compilation
|
---|
| 21 | * @param {string} uri A source uri to decode
|
---|
| 22 | * @returns {boolean|string} False where unmatched else the decoded path
|
---|
| 23 | */
|
---|
| 24 | function decode(uri) {
|
---|
| 25 | return path.isAbsolute(uri) && fs.existsSync(uri) && fs.statSync(uri).isFile() && uri;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | /**
|
---|
| 29 | * Encode the given file path.
|
---|
| 30 | * @this {{options: object}} A loader or compilation
|
---|
| 31 | * @returns {string} A uri
|
---|
| 32 | */
|
---|
| 33 | function encode(absolute) {
|
---|
| 34 | return absolute;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | * The source-map root where relevant.
|
---|
| 39 | * @this {{options: object}} A loader or compilation
|
---|
| 40 | * @returns {string|undefined} The source-map root applicable to any encoded uri
|
---|
| 41 | */
|
---|
| 42 | function root() {
|
---|
| 43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.