Skip to content

Commit

Permalink
📦 NEW: Expose bulk-mail-cli API Functions to developers
Browse files Browse the repository at this point in the history
  • Loading branch information
kumarabhirup committed Jan 1, 2020
1 parent 8cba808 commit 998686b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bulk-mail-cli",
"version": "2.0.2",
"version": "2.0.3",
"description": "Do quick, hassle-free email marketing with this small but very powerful tool! 🔥",
"main": "dist/src/index.js",
"scripts": {
Expand Down
12 changes: 7 additions & 5 deletions src/cli/commands/file/checkJsonConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import BmcConfigurationFile from '../../../typings/configurationFileInterface'
import isConnectionPossible from '../../utils/isConnectionPossible'

export default async function checkJsonConfiguration(
jsonConfiguration: BmcConfigurationFile
jsonConfiguration: BmcConfigurationFile,
shouldLogError = true
): Promise<boolean> {
const errors = []

Expand All @@ -30,10 +31,11 @@ export default async function checkJsonConfiguration(
return true
}

// eslint-disable-next-line array-callback-return
errors.map((error): void => {
console.log(error)
})
// eslint-disable-next-line no-unused-expressions
shouldLogError &&
errors.forEach((error): void => {
console.log(error)
})

return false
}
4 changes: 3 additions & 1 deletion src/cli/utils/checkConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as simplesmtp from 'simplesmtp'
*
* @description Used for checking if the credentials are valid or not.
*/
export const checkConnection = (options, callback): void => {
const checkConnection = (options, callback): void => {
try {
const connection = simplesmtp.connect(options.port, options.host, options)

Expand All @@ -32,3 +32,5 @@ export const checkConnection = (options, callback): void => {
callback('There is an error.')
}
}

export default checkConnection
2 changes: 1 addition & 1 deletion src/cli/utils/isConnectionPossible.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BmcCredentials } from '../../typings/configurationFileInterface'
import { checkConnection } from './checkConnection'
import checkConnection from './checkConnection'
import stringProcessor from './stringProcessor'

export default async function isConnectionPossible(
Expand Down
32 changes: 31 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
export {}
import checkConnection from './cli/utils/checkConnection'
import doesFileExist from './cli/utils/doesFileExist'
import isFileType from './cli/utils/isFileType'
import isForLoop from './cli/utils/isForLoop'
import stringProcessor from './cli/utils/stringProcessor'
import createTransport from './cli/utils/createTransport'
import checkJsonConfiguration from './cli/commands/file/checkJsonConfiguration'

import BmcConfigurationFile, {
BmcAttachment,
BmcConfigurations,
BmcMailSettings,
BmcNonUserData,
BmcCredentials,
} from './typings/configurationFileInterface'

export {
checkConnection,
doesFileExist,
isFileType,
isForLoop,
stringProcessor,
BmcConfigurationFile,
BmcAttachment,
BmcConfigurations,
BmcMailSettings,
BmcNonUserData,
BmcCredentials,
createTransport,
checkJsonConfiguration,
}

0 comments on commit 998686b

Please sign in to comment.