-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import util from 'util'; | ||
|
||
export default function formatWhyRunning(whyRunning) { | ||
const whyRunningArray = []; | ||
const fakeLogger = { | ||
error(...args) { | ||
whyRunningArray.push(util.format(...args)); | ||
}, | ||
}; | ||
|
||
whyRunning(fakeLogger); | ||
|
||
return whyRunningArray | ||
.join('\n') | ||
.split('\n\n') | ||
.filter(entry => { | ||
if (entry.startsWith('There are') || !entry) { | ||
return false; | ||
} | ||
|
||
return entry.split('\n').some(l => l.includes('this._execModule(')); | ||
}) | ||
.map(entry => { | ||
const [title, ...lines] = entry.split('\n'); | ||
|
||
const entries = lines | ||
.map(line => line.split(/\s+-\s+/)) | ||
.map(([file, line]) => ({file, line})); | ||
|
||
return { | ||
entries, | ||
title: title.replace('# ', ''), | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters