11cb0ef41Sopenharmony_ci// Copyright Joyent, Inc. and other Node contributors. 21cb0ef41Sopenharmony_ci// 31cb0ef41Sopenharmony_ci// Permission is hereby granted, free of charge, to any person obtaining a 41cb0ef41Sopenharmony_ci// copy of this software and associated documentation files (the 51cb0ef41Sopenharmony_ci// "Software"), to deal in the Software without restriction, including 61cb0ef41Sopenharmony_ci// without limitation the rights to use, copy, modify, merge, publish, 71cb0ef41Sopenharmony_ci// distribute, sublicense, and/or sell copies of the Software, and to permit 81cb0ef41Sopenharmony_ci// persons to whom the Software is furnished to do so, subject to the 91cb0ef41Sopenharmony_ci// following conditions: 101cb0ef41Sopenharmony_ci// 111cb0ef41Sopenharmony_ci// The above copyright notice and this permission notice shall be included 121cb0ef41Sopenharmony_ci// in all copies or substantial portions of the Software. 131cb0ef41Sopenharmony_ci// 141cb0ef41Sopenharmony_ci// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 151cb0ef41Sopenharmony_ci// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 161cb0ef41Sopenharmony_ci// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 171cb0ef41Sopenharmony_ci// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 181cb0ef41Sopenharmony_ci// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 191cb0ef41Sopenharmony_ci// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 201cb0ef41Sopenharmony_ci// USE OR OTHER DEALINGS IN THE SOFTWARE. 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci'use strict'; 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciconst common = require('../common'); 251cb0ef41Sopenharmony_ciconst assert = require('assert'); 261cb0ef41Sopenharmony_ciconst _module = require('module'); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ciconst cases = { 291cb0ef41Sopenharmony_ci 'WIN': [{ 301cb0ef41Sopenharmony_ci file: 'C:\\Users\\hefangshi\\AppData\\Roaming\ 311cb0ef41Sopenharmony_ci\\npm\\node_modules\\npm\\node_modules\\minimatch', 321cb0ef41Sopenharmony_ci expect: [ 331cb0ef41Sopenharmony_ci 'C:\\Users\\hefangshi\\AppData\\Roaming\ 341cb0ef41Sopenharmony_ci\\npm\\node_modules\\npm\\node_modules\\minimatch\\node_modules', 351cb0ef41Sopenharmony_ci 'C:\\Users\\hefangshi\\AppData\\Roaming\ 361cb0ef41Sopenharmony_ci\\npm\\node_modules\\npm\\node_modules', 371cb0ef41Sopenharmony_ci 'C:\\Users\\hefangshi\\AppData\\Roaming\\npm\\node_modules', 381cb0ef41Sopenharmony_ci 'C:\\Users\\hefangshi\\AppData\\Roaming\\node_modules', 391cb0ef41Sopenharmony_ci 'C:\\Users\\hefangshi\\AppData\\node_modules', 401cb0ef41Sopenharmony_ci 'C:\\Users\\hefangshi\\node_modules', 411cb0ef41Sopenharmony_ci 'C:\\Users\\node_modules', 421cb0ef41Sopenharmony_ci 'C:\\node_modules', 431cb0ef41Sopenharmony_ci ] 441cb0ef41Sopenharmony_ci }, { 451cb0ef41Sopenharmony_ci file: 'C:\\Users\\Rocko Artischocko\\node_stuff\\foo', 461cb0ef41Sopenharmony_ci expect: [ 471cb0ef41Sopenharmony_ci 'C:\\Users\\Rocko Artischocko\\node_stuff\\foo\\node_modules', 481cb0ef41Sopenharmony_ci 'C:\\Users\\Rocko Artischocko\\node_stuff\\node_modules', 491cb0ef41Sopenharmony_ci 'C:\\Users\\Rocko Artischocko\\node_modules', 501cb0ef41Sopenharmony_ci 'C:\\Users\\node_modules', 511cb0ef41Sopenharmony_ci 'C:\\node_modules', 521cb0ef41Sopenharmony_ci ] 531cb0ef41Sopenharmony_ci }, { 541cb0ef41Sopenharmony_ci file: 'C:\\Users\\Rocko Artischocko\\node_stuff\\foo_node_modules', 551cb0ef41Sopenharmony_ci expect: [ 561cb0ef41Sopenharmony_ci 'C:\\Users\\Rocko \ 571cb0ef41Sopenharmony_ciArtischocko\\node_stuff\\foo_node_modules\\node_modules', 581cb0ef41Sopenharmony_ci 'C:\\Users\\Rocko Artischocko\\node_stuff\\node_modules', 591cb0ef41Sopenharmony_ci 'C:\\Users\\Rocko Artischocko\\node_modules', 601cb0ef41Sopenharmony_ci 'C:\\Users\\node_modules', 611cb0ef41Sopenharmony_ci 'C:\\node_modules', 621cb0ef41Sopenharmony_ci ] 631cb0ef41Sopenharmony_ci }, { 641cb0ef41Sopenharmony_ci file: 'C:\\node_modules', 651cb0ef41Sopenharmony_ci expect: [ 661cb0ef41Sopenharmony_ci 'C:\\node_modules', 671cb0ef41Sopenharmony_ci ] 681cb0ef41Sopenharmony_ci }, { 691cb0ef41Sopenharmony_ci file: 'C:\\', 701cb0ef41Sopenharmony_ci expect: [ 711cb0ef41Sopenharmony_ci 'C:\\node_modules', 721cb0ef41Sopenharmony_ci ] 731cb0ef41Sopenharmony_ci }], 741cb0ef41Sopenharmony_ci 'POSIX': [{ 751cb0ef41Sopenharmony_ci file: '/usr/lib/node_modules/npm/node_modules/\ 761cb0ef41Sopenharmony_cinode-gyp/node_modules/glob/node_modules/minimatch', 771cb0ef41Sopenharmony_ci expect: [ 781cb0ef41Sopenharmony_ci '/usr/lib/node_modules/npm/node_modules/\ 791cb0ef41Sopenharmony_cinode-gyp/node_modules/glob/node_modules/minimatch/node_modules', 801cb0ef41Sopenharmony_ci '/usr/lib/node_modules/npm/node_modules/\ 811cb0ef41Sopenharmony_cinode-gyp/node_modules/glob/node_modules', 821cb0ef41Sopenharmony_ci '/usr/lib/node_modules/npm/node_modules/node-gyp/node_modules', 831cb0ef41Sopenharmony_ci '/usr/lib/node_modules/npm/node_modules', 841cb0ef41Sopenharmony_ci '/usr/lib/node_modules', 851cb0ef41Sopenharmony_ci '/usr/node_modules', 861cb0ef41Sopenharmony_ci '/node_modules', 871cb0ef41Sopenharmony_ci ] 881cb0ef41Sopenharmony_ci }, { 891cb0ef41Sopenharmony_ci file: '/usr/test/lib/node_modules/npm/foo', 901cb0ef41Sopenharmony_ci expect: [ 911cb0ef41Sopenharmony_ci '/usr/test/lib/node_modules/npm/foo/node_modules', 921cb0ef41Sopenharmony_ci '/usr/test/lib/node_modules/npm/node_modules', 931cb0ef41Sopenharmony_ci '/usr/test/lib/node_modules', 941cb0ef41Sopenharmony_ci '/usr/test/node_modules', 951cb0ef41Sopenharmony_ci '/usr/node_modules', 961cb0ef41Sopenharmony_ci '/node_modules', 971cb0ef41Sopenharmony_ci ] 981cb0ef41Sopenharmony_ci }, { 991cb0ef41Sopenharmony_ci file: '/usr/test/lib/node_modules/npm/foo_node_modules', 1001cb0ef41Sopenharmony_ci expect: [ 1011cb0ef41Sopenharmony_ci '/usr/test/lib/node_modules/npm/foo_node_modules/node_modules', 1021cb0ef41Sopenharmony_ci '/usr/test/lib/node_modules/npm/node_modules', 1031cb0ef41Sopenharmony_ci '/usr/test/lib/node_modules', 1041cb0ef41Sopenharmony_ci '/usr/test/node_modules', 1051cb0ef41Sopenharmony_ci '/usr/node_modules', 1061cb0ef41Sopenharmony_ci '/node_modules', 1071cb0ef41Sopenharmony_ci ] 1081cb0ef41Sopenharmony_ci }, { 1091cb0ef41Sopenharmony_ci file: '/node_modules', 1101cb0ef41Sopenharmony_ci expect: [ 1111cb0ef41Sopenharmony_ci '/node_modules', 1121cb0ef41Sopenharmony_ci ] 1131cb0ef41Sopenharmony_ci }, { 1141cb0ef41Sopenharmony_ci file: '/', 1151cb0ef41Sopenharmony_ci expect: [ 1161cb0ef41Sopenharmony_ci '/node_modules', 1171cb0ef41Sopenharmony_ci ] 1181cb0ef41Sopenharmony_ci }] 1191cb0ef41Sopenharmony_ci}; 1201cb0ef41Sopenharmony_ci 1211cb0ef41Sopenharmony_ciconst platformCases = common.isWindows ? cases.WIN : cases.POSIX; 1221cb0ef41Sopenharmony_ciplatformCases.forEach((c) => { 1231cb0ef41Sopenharmony_ci const paths = _module._nodeModulePaths(c.file); 1241cb0ef41Sopenharmony_ci assert.deepStrictEqual( 1251cb0ef41Sopenharmony_ci c.expect, paths, 1261cb0ef41Sopenharmony_ci `case ${c.file} failed, actual paths is ${JSON.stringify(paths)}`); 1271cb0ef41Sopenharmony_ci}); 128