-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because normalize-package-data in any case add this field
- Loading branch information
Showing
5 changed files
with
43 additions
and
17 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
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
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
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,32 @@ | ||
import * as path from "path" | ||
import { readJson, readFile } from "fs-extra-p" | ||
|
||
//noinspection JSUnusedLocalSymbols | ||
const __awaiter = require("./awaiter") | ||
|
||
const normalizeData = require("normalize-package-data") | ||
|
||
export async function readPackageJson(file: string): Promise<any> { | ||
const data = await readJson(file) | ||
await authors(file, data) | ||
normalizeData(data) | ||
return data | ||
} | ||
|
||
async function authors(file: string, data: any) { | ||
if (data.contributors != null) { | ||
return | ||
} | ||
|
||
let authorData: string | null = null | ||
try { | ||
authorData = await readFile(path.resolve(path.dirname(file), "AUTHORS"), "utf8") | ||
} | ||
catch (ignored) { | ||
return | ||
} | ||
|
||
data.contributors = authorData | ||
.split(/\r?\n/g) | ||
.map(it => it.replace(/^\s*#.*$/, "").trim()) | ||
} |
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