-
Notifications
You must be signed in to change notification settings - Fork 3
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
3 changed files
with
16 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
import {readFileSync} from 'fs' | ||
import _ from 'lodash' | ||
import path from 'path' | ||
import * as url from 'url' | ||
|
||
const dirname = url.fileURLToPath(new URL('.', import.meta.url)) | ||
const pkg = JSON.parse(readFileSync(path.join(dirname, '..', 'package.json'), {encoding: 'utf-8'})) | ||
const pathToPkg = path.join(dirname, '..', 'package.json') | ||
if (process.env.VERBOSE) { | ||
console.log(`Path to package.json: ${pathToPkg}`) | ||
} | ||
const contents = readFileSync(pathToPkg, {encoding: 'utf-8'}) | ||
if (process.env.VERBOSE) { | ||
console.log(`Contents of package.json: ${_.truncate(contents, {length: 50})}`) | ||
} | ||
|
||
const pkg = JSON.parse(contents) | ||
|
||
export const {name, version} = pkg | ||
export default pkg |