-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
82c90cf
commit 81e8f4c
Showing
11 changed files
with
461 additions
and
33 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
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
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,42 @@ | ||
import * as path from 'path'; | ||
import { type IPackageJson, PackageJsonLookup } from '@rushstack/node-core-library'; | ||
|
||
export class SparoPackage { | ||
private static __sparoPackageJson: IPackageJson | undefined = undefined; | ||
private static __sparoPackageFolder: string | undefined = undefined; | ||
|
||
private constructor() {} | ||
|
||
/** | ||
* The currently executing version of the "sparo" library. | ||
* This is the same as the Sparo tool version for that release. | ||
*/ | ||
public static get version(): string { | ||
return this._sparoPackageJson.version; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
public static get _sparoPackageJson(): IPackageJson { | ||
SparoPackage._ensureOwnPackageJsonIsLoaded(); | ||
return SparoPackage.__sparoPackageJson!; | ||
} | ||
|
||
public static get _sparoPackageFolder(): string { | ||
SparoPackage._ensureOwnPackageJsonIsLoaded(); | ||
return SparoPackage.__sparoPackageFolder!; | ||
} | ||
|
||
private static _ensureOwnPackageJsonIsLoaded(): void { | ||
if (!SparoPackage.__sparoPackageJson) { | ||
const packageJsonFilePath: string | undefined = | ||
PackageJsonLookup.instance.tryGetPackageJsonFilePathFor(__dirname); | ||
if (!packageJsonFilePath) { | ||
throw new Error('Unable to locate the package.json file for this module'); | ||
} | ||
SparoPackage.__sparoPackageFolder = path.dirname(packageJsonFilePath); | ||
SparoPackage.__sparoPackageJson = PackageJsonLookup.instance.loadPackageJson(packageJsonFilePath); | ||
} | ||
} | ||
} |
Oops, something went wrong.