(packageName)
| 91 | }; |
| 92 | |
| 93 | function requireOptionalPeer(packageName) { |
| 94 | const searchPaths = [ |
| 95 | process.cwd(), |
| 96 | path.join(__dirname, '..'), |
| 97 | __dirname, |
| 98 | ]; |
| 99 | for (const searchPath of searchPaths) { |
| 100 | try { |
| 101 | return require(require.resolve(packageName, { paths: [searchPath] })); |
| 102 | } catch (e) { |
| 103 | // Try the next search path. |
| 104 | } |
| 105 | } |
| 106 | return null; |
| 107 | } |
| 108 | |
| 109 | // Detect optional opencc-jieba plugin package. |
| 110 | // When installed, jieba-based configs (e.g. s2twp_jieba.json) become available. |