1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-14 23:50:06 +00:00

fix(fs): replace fs imports with locally defined WriteStream interface

This commit is contained in:
Krishna Acondy
2021-07-23 22:24:04 +01:00
parent 2a9526d056
commit 0a6c5a0ec4
5 changed files with 9 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
import { Job } from '../..' import { Job } from '../..'
import { RequestClient } from '../../request/RequestClient' import { RequestClient } from '../../request/RequestClient'
import { fetchLog } from '../../utils' import { fetchLog } from '../../utils'
import { WriteStream } from 'fs' import { WriteStream } from '../../types'
import { writeStream } from './writeStream' import { writeStream } from './writeStream'
/** /**

View File

@@ -1,11 +1,11 @@
import { WriteStream } from 'fs' import { WriteStream } from '../../types'
export const writeStream = async ( export const writeStream = async (
stream: WriteStream, stream: WriteStream,
content: string content: string
): Promise<void> => { ): Promise<void> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
stream.write(content + '\n\nnext chunk\n\n', (e) => { stream.write(content + '\n', (e) => {
if (e) { if (e) {
return reject(e) return reject(e)
} }

4
src/types/WriteStream.ts Normal file
View File

@@ -0,0 +1,4 @@
export interface WriteStream {
write: (content: string, callback: (err?: Error) => any) => void
path: string
}

View File

@@ -11,3 +11,4 @@ export * from './SASjsRequest'
export * from './Session' export * from './Session'
export * from './UploadFile' export * from './UploadFile'
export * from './PollOptions' export * from './PollOptions'
export * from './WriteStream'

View File

@@ -1,6 +1,7 @@
export * from './asyncForEach' export * from './asyncForEach'
export * from './compareTimestamps' export * from './compareTimestamps'
export * from './convertToCsv' export * from './convertToCsv'
export * from './isNode'
export * from './isRelativePath' export * from './isRelativePath'
export * from './isUri' export * from './isUri'
export * from './isUrl' export * from './isUrl'