From 64cfe271ca702ba546c693f13ca7945e15e137f0 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Thu, 29 Jun 2023 18:00:38 +0200 Subject: [PATCH] fix imports in rangement --- rangement/finders.mjs | 5 ++++- rangement/index.mjs | 6 +++--- rangement/{index.test.js => main.test.js} | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) rename rangement/{index.test.js => main.test.js} (63%) diff --git a/rangement/finders.mjs b/rangement/finders.mjs index f03dc17b..46ec0d4a 100644 --- a/rangement/finders.mjs +++ b/rangement/finders.mjs @@ -1,8 +1,11 @@ /** * la classe qui repère des patterns */ -import {tagSectionSeparator} from "./configs"; +import {tagSectionSeparator} from "./configs.mjs"; +/** + * finds patterns for file name + */ export default class finders{ diff --git a/rangement/index.mjs b/rangement/index.mjs index 7132a88b..a905329a 100644 --- a/rangement/index.mjs +++ b/rangement/index.mjs @@ -6,7 +6,7 @@ import finders from './finders.mjs' // }) import exifr from 'exifr' import moment from 'moment' -import {tagSectionSeparator, tagSeparator} from "./configs"; +import {tagSectionSeparator, tagSeparator} from "./configs.mjs"; const pathFolder = '/home/poule/encrypted/stockage-syncable/photos/a_dispatcher/tout' const sortingFolder = '/home/poule/encrypted/stockage-syncable/photos/a_dispatcher' @@ -148,7 +148,7 @@ if (fileMixedNewName !== originalFileName) { function addTagInFileName(tagName, fileName) { let tags = findTagSectionInString(fileName) - let firstPart = findFileNameFreeTextPart(fileName) + let firstPart = finders.findFileNameFreeTextPart(fileName) tags.push(tagName) let uniqueArray = [...new Set(tags)] @@ -168,7 +168,7 @@ const fileDefinition = { function destructurateFileName(fileName) { return { dateStamp: finders.findFormattedDate(fileName), - freeText: findFileNameFreeTextPart(fileName), + freeText: finders.findFileNameFreeTextPart(fileName), tags: findTagSectionInString(fileName), extension: finders.findFileExtension(fileName), } diff --git a/rangement/index.test.js b/rangement/main.test.js similarity index 63% rename from rangement/index.test.js rename to rangement/main.test.js index be85fbfd..f4ef9939 100644 --- a/rangement/index.test.js +++ b/rangement/main.test.js @@ -1,11 +1,14 @@ -// import finders from "./finders.mjs"; -const finders = require('./finders.mjs') +import finders from "./finders.mjs"; +// const finders = require('./finders.mjs') describe('rangement file name', () => { test('detects date in file name', () => { expect(finders.findFormattedDate('2023-06-23T18.36.47 -- machin bidule.jpg')).toBe('2023-06-23T18.36.47'); }); + test('detects file extension in file name', () => { + expect(finders.findFileExtension()('2023-06-23T18.36.47 -- machin bidule.jpg')).toBe('jpg'); + }); }) console.log('finders', finders)