refactor(core): Replace promisify-d node calls with native promises (no-changelog) (#8464)
This commit is contained in:
committed by
GitHub
parent
238b54c77b
commit
5cb55270b7
@@ -1,7 +1,8 @@
|
||||
import type { BinaryToTextEncoding } from 'crypto';
|
||||
import { createHash, createHmac, createSign, getHashes, randomBytes } from 'crypto';
|
||||
import stream from 'stream';
|
||||
import { promisify } from 'util';
|
||||
import { pipeline } from 'stream/promises';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import set from 'lodash/set';
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
@@ -10,11 +11,6 @@ import type {
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { deepCopy, BINARY_ENCODING } from 'n8n-workflow';
|
||||
import set from 'lodash/set';
|
||||
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
const pipeline = promisify(stream.pipeline);
|
||||
|
||||
const unsupportedAlgorithms = [
|
||||
'RSA-MD4',
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { parse as pathParse } from 'path';
|
||||
import { writeFile as fsWriteFile } from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import { writeFile as fsWriteFile } from 'fs/promises';
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
@@ -14,7 +13,6 @@ import type {
|
||||
import { deepCopy } from 'n8n-workflow';
|
||||
import gm from 'gm';
|
||||
import { file } from 'tmp-promise';
|
||||
const fsWriteFileAsync = promisify(fsWriteFile);
|
||||
import getSystemFonts from 'get-system-fonts';
|
||||
|
||||
const nodeOperations: INodePropertyOptions[] = [
|
||||
@@ -1117,9 +1115,9 @@ export class EditImage implements INodeType {
|
||||
binaryPropertyName,
|
||||
);
|
||||
|
||||
const { fd, path, cleanup } = await file();
|
||||
const { path, cleanup } = await file();
|
||||
cleanupFunctions.push(cleanup);
|
||||
await fsWriteFileAsync(fd, binaryDataBuffer);
|
||||
await fsWriteFile(path, binaryDataBuffer);
|
||||
|
||||
if (operations[0].operation === 'create') {
|
||||
// It seems like if the image gets created newly we have to create a new gm instance
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { createWriteStream } from 'fs';
|
||||
import { basename, dirname } from 'path';
|
||||
import type { Readable } from 'stream';
|
||||
import { pipeline } from 'stream';
|
||||
import { promisify } from 'util';
|
||||
import { pipeline } from 'stream/promises';
|
||||
import { file as tmpFile } from 'tmp-promise';
|
||||
import ftpClient from 'promise-ftp';
|
||||
import sftpClient from 'ssh2-sftp-client';
|
||||
import { BINARY_ENCODING, NodeApiError } from 'n8n-workflow';
|
||||
import type {
|
||||
ICredentialDataDecryptedObject,
|
||||
@@ -16,10 +18,6 @@ import type {
|
||||
INodeTypeDescription,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { file as tmpFile } from 'tmp-promise';
|
||||
|
||||
import ftpClient from 'promise-ftp';
|
||||
import sftpClient from 'ssh2-sftp-client';
|
||||
import { formatPrivateKey } from '@utils/utilities';
|
||||
|
||||
interface ReturnFtpItem {
|
||||
@@ -40,8 +38,6 @@ interface ReturnFtpItem {
|
||||
path: string;
|
||||
}
|
||||
|
||||
const streamPipeline = promisify(pipeline);
|
||||
|
||||
async function callRecursiveList(
|
||||
path: string,
|
||||
client: sftpClient | ftpClient,
|
||||
@@ -722,7 +718,7 @@ export class Ftp implements INodeType {
|
||||
const binaryFile = await tmpFile({ prefix: 'n8n-sftp-' });
|
||||
try {
|
||||
const stream = await ftp!.get(path);
|
||||
await streamPipeline(stream, createWriteStream(binaryFile.path));
|
||||
await pipeline(stream, createWriteStream(binaryFile.path));
|
||||
|
||||
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
|
||||
const remoteFilePath = this.getNodeParameter('path', i) as string;
|
||||
|
||||
Reference in New Issue
Block a user