1 | 'use strict';
|
---|
2 |
|
---|
3 | var assert = require('assert');
|
---|
4 | var path = require('path');
|
---|
5 | var resolve = require('resolve');
|
---|
6 |
|
---|
7 | var basedir = __dirname + '/node_modules/@my-scope/package-b';
|
---|
8 |
|
---|
9 | var expected = path.join(__dirname, '../../node_modules/jquery/dist/jquery.js');
|
---|
10 |
|
---|
11 | /*
|
---|
12 | * preserveSymlinks === false
|
---|
13 | * will search NPM package from
|
---|
14 | * - packages/package-b/node_modules
|
---|
15 | * - packages/node_modules
|
---|
16 | * - node_modules
|
---|
17 | */
|
---|
18 | assert.equal(resolve.sync('jquery', { basedir: basedir, preserveSymlinks: false }), expected);
|
---|
19 | assert.equal(resolve.sync('../../node_modules/jquery', { basedir: basedir, preserveSymlinks: false }), expected);
|
---|
20 |
|
---|
21 | /*
|
---|
22 | * preserveSymlinks === true
|
---|
23 | * will search NPM package from
|
---|
24 | * - packages/package-a/node_modules/@my-scope/packages/package-b/node_modules
|
---|
25 | * - packages/package-a/node_modules/@my-scope/packages/node_modules
|
---|
26 | * - packages/package-a/node_modules/@my-scope/node_modules
|
---|
27 | * - packages/package-a/node_modules/node_modules
|
---|
28 | * - packages/package-a/node_modules
|
---|
29 | * - packages/node_modules
|
---|
30 | * - node_modules
|
---|
31 | */
|
---|
32 | assert.equal(resolve.sync('jquery', { basedir: basedir, preserveSymlinks: true }), expected);
|
---|
33 | assert.equal(resolve.sync('../../../../../node_modules/jquery', { basedir: basedir, preserveSymlinks: true }), expected);
|
---|
34 |
|
---|
35 | console.log(' * all monorepo paths successfully resolved through symlinks');
|
---|