UNPKG

725 BJavaScriptView Raw
1/*
2 Copyright (c) 2014 Google Inc. All rights reserved.
3
4 Use of this source code is governed by the MIT License, available in this package's LICENSE file
5 or at http://opensource.org/licenses/MIT.
6 */
7'use strict';
8
9var path = require('path');
10
11function requirePaths(parentModule, paths) {
12 if (!parentModule) {
13 return paths;
14 }
15
16 return paths.slice(0).map(function(p) {
17 return path.resolve(parentModule.filepath, p);
18 });
19}
20
21exports.before = function before(targetPath, parentModule, opts) {
22 var resolvedPaths = requirePaths(parentModule, opts);
23 return 'module.paths = ' + JSON.stringify(resolvedPaths) + '.concat(module.paths);\n';
24};
25
26exports.after = function after(targetPath, parentModule, opts) {
27 return '';
28};