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:
@@ -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'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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
4
src/types/WriteStream.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export interface WriteStream {
|
||||||
|
write: (content: string, callback: (err?: Error) => any) => void
|
||||||
|
path: string
|
||||||
|
}
|
||||||
@@ -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'
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
Reference in New Issue
Block a user