mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-10 16:00:28 -07:00
Use async fileExists
This commit is contained in:
parent
99160eadb3
commit
28192d7723
5 changed files with 21 additions and 15 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import fs from 'fs';
|
||||
import { getContainer, getFileAbosluteDir, getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||
import {
|
||||
fileExists, getContainer, getFileAbosluteDir, getFileName,
|
||||
} from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||
import {
|
||||
IpluginDetails,
|
||||
IpluginInputArgs,
|
||||
|
|
@ -57,7 +58,7 @@ const details = (): IpluginDetails => ({
|
|||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
|
||||
const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||
const lib = require('../../../../../methods/lib')();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
|
|
@ -71,9 +72,9 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
|
|||
fileToCheck = fileToCheck.replace(/\${container}/g, getContainer(args.inputFileObj._id));
|
||||
fileToCheck = `${directory}/${fileToCheck}`;
|
||||
|
||||
let fileExists = false;
|
||||
if (fs.existsSync(fileToCheck)) {
|
||||
fileExists = true;
|
||||
let fileDoesExist = false;
|
||||
if (await fileExists(fileToCheck)) {
|
||||
fileDoesExist = true;
|
||||
args.jobLog(`File exists: ${fileToCheck}`);
|
||||
} else {
|
||||
args.jobLog(`File does not exist: ${fileToCheck}`);
|
||||
|
|
@ -81,7 +82,7 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
|
|||
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
outputNumber: fileExists ? 1 : 2,
|
||||
outputNumber: fileDoesExist ? 1 : 2,
|
||||
variables: args.variables,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue