From ddc7b0493fab7834743628d4def863c00c0ae553 Mon Sep 17 00:00:00 2001 From: AlejandroHerr Date: Sat, 15 Dec 2018 01:45:08 +0100 Subject: [PATCH] refactor: Restructure under lib folder --- src/Bus/index.ts | 5 ----- src/Device/index.ts | 5 ----- src/index.ts | 13 ++++++++----- src/{Bus => lib}/Bus.spec.ts | 4 ++-- src/{Bus => lib}/Bus.ts | 3 +-- src/{Bus => lib}/BusError.ts | 0 src/{Bus => lib}/BusInterface.ts | 2 +- src/{Device => lib}/Device.spec.ts | 4 ++-- src/{Device => lib}/Device.ts | 3 +-- src/{Device => lib}/DeviceError.ts | 0 src/{Device => lib}/DeviceInterface.ts | 2 +- .../index.ts => lib/createI2cBusMock.ts} | 0 src/{ => lib}/types.ts | 0 13 files changed, 16 insertions(+), 25 deletions(-) delete mode 100644 src/Bus/index.ts delete mode 100644 src/Device/index.ts rename src/{Bus => lib}/Bus.spec.ts (96%) rename src/{Bus => lib}/Bus.ts (98%) rename src/{Bus => lib}/BusError.ts (100%) rename src/{Bus => lib}/BusInterface.ts (96%) rename src/{Device => lib}/Device.spec.ts (94%) rename src/{Device => lib}/Device.ts (96%) rename src/{Device => lib}/DeviceError.ts (100%) rename src/{Device => lib}/DeviceInterface.ts (93%) rename src/{createI2cBusMock/index.ts => lib/createI2cBusMock.ts} (100%) rename src/{ => lib}/types.ts (100%) diff --git a/src/Bus/index.ts b/src/Bus/index.ts deleted file mode 100644 index b8e7289..0000000 --- a/src/Bus/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import Bus from './Bus'; -import BusError from './BusError'; -import BusInterface from './BusInterface'; - -export { Bus, BusError, BusInterface }; diff --git a/src/Device/index.ts b/src/Device/index.ts deleted file mode 100644 index 04f4875..0000000 --- a/src/Device/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import Device from './Device'; -import DeviceError from './DeviceError'; -import DeviceInterface from './DeviceInterface'; - -export { Device, DeviceError, DeviceInterface }; diff --git a/src/index.ts b/src/index.ts index 74b24a4..1131426 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,9 @@ -import { Bus, BusError, BusInterface } from './Bus'; -import { Device, DeviceError, DeviceInterface } from './Device'; +import Bus from './lib/Bus'; +import BusError from './lib/BusError'; +import BusInterface from './lib/BusInterface'; +import createI2cBusMock from './lib/createI2cBusMock'; +import Device from './lib/Device'; +import DeviceError from './lib/DeviceError'; +import DeviceInterface from './lib/DeviceInterface'; -import createI2cBusMock from './createI2cBusMock'; - -export { Bus, BusError, BusInterface, Device, DeviceError, DeviceInterface, createI2cBusMock }; +export { Bus, BusError, BusInterface, createI2cBusMock, Device, DeviceError, DeviceInterface }; diff --git a/src/Bus/Bus.spec.ts b/src/lib/Bus.spec.ts similarity index 96% rename from src/Bus/Bus.spec.ts rename to src/lib/Bus.spec.ts index 0152c0e..13c95e0 100644 --- a/src/Bus/Bus.spec.ts +++ b/src/lib/Bus.spec.ts @@ -1,9 +1,9 @@ -import { I2cBusPromised } from '../types'; import Bus from './Bus'; import BusError from './BusError'; +import { I2cBusPromised } from './types'; jest.mock('i2c-bus', () => { - const createI2cBusMock = require('../createI2cBusMock').default; // eslint-disable-line global-require + const createI2cBusMock = require('./createI2cBusMock').default; // eslint-disable-line global-require return { open: createI2cBusMock({ diff --git a/src/Bus/Bus.ts b/src/lib/Bus.ts similarity index 98% rename from src/Bus/Bus.ts rename to src/lib/Bus.ts index 59258f7..f46e85f 100644 --- a/src/Bus/Bus.ts +++ b/src/lib/Bus.ts @@ -1,10 +1,9 @@ import { promisifyAll } from 'bluebird'; import { open as openI2cBus } from 'i2c-bus'; -import { I2cBusPromised } from '../types'; - import BusError from './BusError'; import BusInterface from './BusInterface'; +import { I2cBusPromised } from './types'; const Bus = ({ busNumber = 1, openBus = openI2cBus } = {}): BusInterface => { let i2cBus: I2cBusPromised | null = null; diff --git a/src/Bus/BusError.ts b/src/lib/BusError.ts similarity index 100% rename from src/Bus/BusError.ts rename to src/lib/BusError.ts diff --git a/src/Bus/BusInterface.ts b/src/lib/BusInterface.ts similarity index 96% rename from src/Bus/BusInterface.ts rename to src/lib/BusInterface.ts index cdee7b3..e7db0af 100644 --- a/src/Bus/BusInterface.ts +++ b/src/lib/BusInterface.ts @@ -1,6 +1,6 @@ import { I2cBusFuncs } from 'i2c-bus'; -import { I2cBusPromised } from '../types'; +import { I2cBusPromised } from './types'; export default interface BusInterface { readonly busNumber: number; diff --git a/src/Device/Device.spec.ts b/src/lib/Device.spec.ts similarity index 94% rename from src/Device/Device.spec.ts rename to src/lib/Device.spec.ts index e54777a..e84d83a 100644 --- a/src/Device/Device.spec.ts +++ b/src/lib/Device.spec.ts @@ -1,8 +1,8 @@ -import { Bus } from '../Bus'; +import Bus from './Bus'; import Device from './Device'; jest.mock('i2c-bus', () => { - const createI2cBusMock = require('../createI2cBusMock').default; // eslint-disable-line global-require + const createI2cBusMock = require('./createI2cBusMock').default; // eslint-disable-line global-require return { open: createI2cBusMock({ diff --git a/src/Device/Device.ts b/src/lib/Device.ts similarity index 96% rename from src/Device/Device.ts rename to src/lib/Device.ts index 6542076..c0513b9 100644 --- a/src/Device/Device.ts +++ b/src/lib/Device.ts @@ -1,5 +1,4 @@ -import BusInterface from '../Bus/BusInterface'; - +import BusInterface from './BusInterface'; import DeviceInterface from './DeviceInterface'; const Device = ({ address, bus }: { address: number; bus: BusInterface }): DeviceInterface => ({ diff --git a/src/Device/DeviceError.ts b/src/lib/DeviceError.ts similarity index 100% rename from src/Device/DeviceError.ts rename to src/lib/DeviceError.ts diff --git a/src/Device/DeviceInterface.ts b/src/lib/DeviceInterface.ts similarity index 93% rename from src/Device/DeviceInterface.ts rename to src/lib/DeviceInterface.ts index fceb82f..0ca9bd2 100644 --- a/src/Device/DeviceInterface.ts +++ b/src/lib/DeviceInterface.ts @@ -1,4 +1,4 @@ -import BusInterface from '../Bus/BusInterface'; +import BusInterface from './BusInterface'; export default interface DeviceInterface { readonly address: number; diff --git a/src/createI2cBusMock/index.ts b/src/lib/createI2cBusMock.ts similarity index 100% rename from src/createI2cBusMock/index.ts rename to src/lib/createI2cBusMock.ts diff --git a/src/types.ts b/src/lib/types.ts similarity index 100% rename from src/types.ts rename to src/lib/types.ts