UNPKG

698 BJavaScriptView Raw
1'use strict';
2
3const path = require('path');
4const ensurePosix = require('ensure-posix-path');
5const { moduleResolve } = require('amd-name-resolver');
6
7const BASE_DIR = path.resolve(`${__dirname}/..`);
8
9function getRelativeModulePath(modulePath) {
10 return ensurePosix(path.relative(process.cwd(), modulePath));
11}
12
13function resolveRelativeModulePath(name, child) {
14 return moduleResolve(name, getRelativeModulePath(child));
15}
16
17module.exports = {
18 getRelativeModulePath,
19 resolveRelativeModulePath
20};
21
22Object.keys(module.exports).forEach((key) => {
23 module.exports[key].baseDir = () => BASE_DIR;
24
25 module.exports[key]._parallelBabel = {
26 requireFile: __filename,
27 useMethod: key
28 };
29});