ソースを参照

add explicit return typings to builder utils

Nicholas Bollweg 4 年 前
コミット
936594672b
1 ファイル変更8 行追加8 行削除
  1. 8 8
      buildutils/src/utils.ts

+ 8 - 8
buildutils/src/utils.ts

@@ -137,7 +137,7 @@ export function fromTemplate(
   templ: string,
   subs: Dict<string>,
   options: { autoindent?: boolean; end?: string } = {}
-) {
+): string {
   // default options values
   const autoindent =
     options.autoindent === undefined ? true : options.autoindent;
@@ -166,7 +166,7 @@ export function fromTemplate(
  *
  * Call a command, checking its status.
  */
-export function checkStatus(cmd: string) {
+export function checkStatus(cmd: string): number | null {
   const data = childProcess.spawnSync(cmd, { shell: true });
   return data.status;
 }
@@ -174,7 +174,7 @@ export function checkStatus(cmd: string) {
 /**
  * Get the current version of JupyterLab
  */
-export function getPythonVersion() {
+export function getPythonVersion(): string {
   const cmd = 'python setup.py --version';
   return run(cmd, { stdio: 'pipe' }, true);
 }
@@ -182,7 +182,7 @@ export function getPythonVersion() {
 /**
  * Get the current version of a package
  */
-export function getJSVersion(pkg: string) {
+export function getJSVersion(pkg: string): string {
   const filePath = path.resolve(
     path.join('.', 'packages', pkg, 'package.json')
   );
@@ -193,7 +193,7 @@ export function getJSVersion(pkg: string) {
 /**
  * Pre-bump.
  */
-export function prebump() {
+export function prebump(): void {
   // Ensure bump2version is installed (active fork of bumpversion)
   run('python -m pip install bump2version');
 
@@ -215,7 +215,7 @@ ${status}`
 /**
  * Post-bump.
  */
-export function postbump() {
+export function postbump(): void {
   // Get the current version.
   const curr = getPythonVersion();
 
@@ -313,7 +313,7 @@ export function getPackageGraph(): DepGraph<Dict<unknown>> {
  * We could just use "require(`${depName}/package.json`)", however this won't work for modules
  * that are not hoisted to the top level.
  */
-function requirePackage(parentModule: string, module: string) {
+function requirePackage(parentModule: string, module: string): NodeRequire {
   const packagePath = `${module}/package.json`;
   let parentModulePath: string;
   // This will fail when the parent module cannot be loaded, like `@jupyterlab/test-root`
@@ -331,7 +331,7 @@ function requirePackage(parentModule: string, module: string) {
 /**
  * Ensure the given path uses '/' as path separator.
  */
-export function ensureUnixPathSep(source: string) {
+export function ensureUnixPathSep(source: string): string {
   if (path.sep === '/') {
     return source;
   }