From 6bf80edf5492224264cdd43b3fb9c90225ab52dd Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 13 Dec 2018 15:00:38 -0800 Subject: [PATCH] ci: add golden-api file for core/node This is necessary as we introduce namespaces in jobs. --- .../node/{index.d.ts => _golden-api.d.ts} | 7 ++- .../angular_devkit/core/node/_golden-api.ts | 11 ++++ packages/angular_devkit/core/node/fs.ts | 51 +++++++++---------- packages/angular_devkit/core/node/index.ts | 6 ++- packages/angular_devkit/core/node/resolve.ts | 8 +-- 5 files changed, 47 insertions(+), 36 deletions(-) rename etc/api/angular_devkit/core/node/{index.d.ts => _golden-api.d.ts} (94%) create mode 100644 packages/angular_devkit/core/node/_golden-api.ts diff --git a/etc/api/angular_devkit/core/node/index.d.ts b/etc/api/angular_devkit/core/node/_golden-api.d.ts similarity index 94% rename from etc/api/angular_devkit/core/node/index.d.ts rename to etc/api/angular_devkit/core/node/_golden-api.d.ts index 6c2e882fc1..285d1d188b 100644 --- a/etc/api/angular_devkit/core/node/index.d.ts +++ b/etc/api/angular_devkit/core/node/_golden-api.d.ts @@ -1,9 +1,8 @@ export declare function createConsoleLogger(verbose?: boolean, stdout?: ProcessOutput, stderr?: ProcessOutput): logging.Logger; -export declare namespace fs { - function isFile(filePath: string): boolean; - function isDirectory(filePath: string): boolean; -} +export declare function isDirectory(filePath: string): boolean; + +export declare function isFile(filePath: string): boolean; export declare class ModuleNotFoundException extends BaseException { readonly basePath: string; diff --git a/packages/angular_devkit/core/node/_golden-api.ts b/packages/angular_devkit/core/node/_golden-api.ts new file mode 100644 index 0000000000..1008bfa1c3 --- /dev/null +++ b/packages/angular_devkit/core/node/_golden-api.ts @@ -0,0 +1,11 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +export * from './fs'; +export * from './cli-logger'; +export * from './host'; +export { ModuleNotFoundException, ResolveOptions, resolve } from './resolve'; diff --git a/packages/angular_devkit/core/node/fs.ts b/packages/angular_devkit/core/node/fs.ts index 7f37baef6a..f6df37c3cb 100644 --- a/packages/angular_devkit/core/node/fs.ts +++ b/packages/angular_devkit/core/node/fs.ts @@ -7,34 +7,31 @@ */ import { statSync } from 'fs'; -export namespace fs { - export function isFile(filePath: string): boolean { - let stat; - try { - stat = statSync(filePath); - } catch (e) { - if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) { - return false; - } - throw e; +export function isFile(filePath: string): boolean { + let stat; + try { + stat = statSync(filePath); + } catch (e) { + if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) { + return false; } - - return stat.isFile() || stat.isFIFO(); - } - - - export function isDirectory(filePath: string): boolean { - let stat; - try { - stat = statSync(filePath); - } catch (e) { - if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) { - return false; - } - throw e; - } - - return stat.isDirectory(); + throw e; } + return stat.isFile() || stat.isFIFO(); +} + + +export function isDirectory(filePath: string): boolean { + let stat; + try { + stat = statSync(filePath); + } catch (e) { + if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) { + return false; + } + throw e; + } + + return stat.isDirectory(); } diff --git a/packages/angular_devkit/core/node/index.ts b/packages/angular_devkit/core/node/index.ts index 1008bfa1c3..22d6d35a53 100644 --- a/packages/angular_devkit/core/node/index.ts +++ b/packages/angular_devkit/core/node/index.ts @@ -5,7 +5,11 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -export * from './fs'; +import * as fs from './fs'; export * from './cli-logger'; export * from './host'; export { ModuleNotFoundException, ResolveOptions, resolve } from './resolve'; + +export { + fs, +}; diff --git a/packages/angular_devkit/core/node/resolve.ts b/packages/angular_devkit/core/node/resolve.ts index 1faaf247e0..5a3e0712e6 100644 --- a/packages/angular_devkit/core/node/resolve.ts +++ b/packages/angular_devkit/core/node/resolve.ts @@ -8,7 +8,7 @@ import * as fs from 'fs'; import * as path from 'path'; import { BaseException } from '../src'; -import { fs as devkitFs } from './fs'; +import { isFile } from './fs'; /** * Exception thrown when a module could not be resolved. @@ -204,16 +204,16 @@ export function resolve(x: string, options: ResolveOptions): string { throw new ModuleNotFoundException(x, basePath); function loadAsFileSync(x: string): string | null { - if (devkitFs.isFile(x)) { + if (isFile(x)) { return x; } - return extensions.map(ex => x + ex).find(f => devkitFs.isFile(f)) || null; + return extensions.map(ex => x + ex).find(f => isFile(f)) || null; } function loadAsDirectorySync(x: string): string | null { const pkgfile = path.join(x, 'package.json'); - if (devkitFs.isFile(pkgfile)) { + if (isFile(pkgfile)) { if (options.resolvePackageJson) { return pkgfile; }