Skip to content

Commit

Permalink
feat(interfaces): Directories
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Dec 1, 2022
1 parent ab8a328 commit 0387945
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/interfaces/__tests__/directories.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @file Unit Tests - Directories
* @module pkg-types/interfaces/tests/Directories
*/

import type TestSubject from '../directories'

describe('unit:interfaces/Directories', () => {
it('should allow empty object', () => {
assertType<TestSubject>({})
})

it('should allow object that only has property "bin"', () => {
assertType<TestSubject>({ bin: './dist/bin' })
})

it('should allow object that only has property "doc"', () => {
assertType<TestSubject>({ doc: './dist/docs' })
})

it('should allow object that only has property "example"', () => {
assertType<TestSubject>({ example: './dist/docs/examples' })
})

it('should allow object that only has property "lib"', () => {
assertType<TestSubject>({ lib: './dist/lib' })
})

it('should allow object that only has property "man"', () => {
assertType<TestSubject>({ man: './dist/man' })
})

it('should allow object that only has property "src"', () => {
assertType<TestSubject>({ src: './src' })
})

it('should allow object that only has property "test"', () => {
assertType<TestSubject>({ test: './__tests__' })
})

it('should allow object with all properties', () => {
assertType<Required<TestSubject>>({
bin: './dist/bin',
doc: './dist/docs',
example: './dist/docs/examples',
lib: './dist/lib',
man: './dist/man',
src: './src',
test: './__tests__'
})
})

it('should allow object with unknown key', () => {
assertType<TestSubject>({ jars: 'java' })
})
})
51 changes: 51 additions & 0 deletions src/interfaces/directories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @file Interfaces - Directories
* @module pkg-types/interfaces/Directories
*/

/**
* Package structure indicator.
*
* @see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#directories
* @see https://wiki.commonjs.org/wiki/Packages/1.0#Package_Directory_Layout
*/
interface Directories {
[type: string]: string

/**
* Relative path to directory containing executable files.
*/
bin?: string

/**
* Relative path to directory containing documentation.
*/
doc?: string

/**
* Relative path to directory containing package usage examples.
*/
example?: string

/**
* Relative path to directory containing distribution code.
*/
lib?: string

/**
* Relative path to directory containing man pages.
*/
man?: string

/**
* Relative path to directory containing source code.
*/
src?: string

/**
* Relative path to directory containing test files.
*/
test?: string
}

export type { Directories as default }
1 change: 1 addition & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

export type { default as BugsObject } from './bugs-object'
export type { default as DependencyMeta } from './dependency-meta'
export type { default as Directories } from './directories'
export type { default as FundingInfo } from './funding-info'
export type { default as InstallConfig } from './install-config'
export type { default as LicenseObject } from './license-object'
Expand Down

0 comments on commit 0387945

Please sign in to comment.