Changeset e29cc2e for trip-planner-front/node_modules/lilconfig/dist
- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/node_modules/lilconfig/dist/index.js
r59329aa re29cc2e 135 135 async load(filepath) { 136 136 validateFilePath(filepath); 137 const { base, ext } = path.parse(filepath); 137 const absPath = path.resolve(process.cwd(), filepath); 138 const { base, ext } = path.parse(absPath); 138 139 const loaderKey = ext || 'noExt'; 139 140 const loader = loaders[loaderKey]; 140 141 validateLoader(loader, loaderKey); 141 const content = String(await fsReadFileAsync( filepath));142 const content = String(await fsReadFileAsync(absPath)); 142 143 if (base === 'package.json') { 143 const pkg = await loader( filepath, content);144 const pkg = await loader(absPath, content); 144 145 return transform({ 145 146 config: getPackageProp(packageProp, pkg), 146 filepath ,147 }); 148 } 149 const result = { 150 config: null, 151 filepath ,147 filepath: absPath, 148 }); 149 } 150 const result = { 151 config: null, 152 filepath: absPath, 152 153 }; 153 154 const isEmpty = content.trim() === ''; … … 155 156 return transform({ 156 157 config: undefined, 157 filepath ,158 filepath: absPath, 158 159 isEmpty: true, 159 160 }); 160 161 result.config = isEmpty 161 162 ? undefined 162 : await loader( filepath, content);163 : await loader(absPath, content); 163 164 return transform(isEmpty ? { ...result, isEmpty, config: undefined } : result); 164 165 }, … … 215 216 load(filepath) { 216 217 validateFilePath(filepath); 217 const { base, ext } = path.parse(filepath); 218 const absPath = path.resolve(process.cwd(), filepath); 219 const { base, ext } = path.parse(absPath); 218 220 const loaderKey = ext || 'noExt'; 219 221 const loader = loaders[loaderKey]; 220 222 validateLoader(loader, loaderKey); 221 const content = String(fs.readFileSync( filepath));223 const content = String(fs.readFileSync(absPath)); 222 224 if (base === 'package.json') { 223 const pkg = loader( filepath, content);225 const pkg = loader(absPath, content); 224 226 return transform({ 225 227 config: getPackageProp(packageProp, pkg), 226 filepath ,227 }); 228 } 229 const result = { 230 config: null, 231 filepath ,228 filepath: absPath, 229 }); 230 } 231 const result = { 232 config: null, 233 filepath: absPath, 232 234 }; 233 235 const isEmpty = content.trim() === ''; 234 236 if (isEmpty && ignoreEmptySearchPlaces) 235 237 return transform({ 236 filepath ,238 filepath: absPath, 237 239 config: undefined, 238 240 isEmpty: true, 239 241 }); 240 result.config = isEmpty ? undefined : loader( filepath, content);242 result.config = isEmpty ? undefined : loader(absPath, content); 241 243 return transform(isEmpty ? { ...result, isEmpty, config: undefined } : result); 242 244 },
Note:
See TracChangeset
for help on using the changeset viewer.