Make n8n work with older node versions (<10)

This commit is contained in:
Jan Oberhauser
2019-06-24 12:47:44 +02:00
parent b53d4c56ae
commit 034c70f6ab
5 changed files with 41 additions and 15 deletions

View File

@@ -5,7 +5,12 @@ import {
INodeType,
} from 'n8n-workflow';
import { promises as fs } from 'fs';
import {
readFile as fsReadFile,
} from 'fs';
import { promisify } from "util";
const fsReadFileAsync = promisify(fsReadFile);
export class ReadBinaryFile implements INodeType {
@@ -55,7 +60,7 @@ export class ReadBinaryFile implements INodeType {
let data;
try {
data = await fs.readFile(filePath) as Buffer;
data = await fsReadFileAsync(filePath) as Buffer;
} catch (error) {
if (error.code === 'ENOENT') {
throw new Error(`The file "${filePath}" could not be found.`);