testing config
This commit is contained in:
parent
64cfe271ca
commit
6d699231fc
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
export const tagSeparator = ' '
|
export const tagSeparator = ' '
|
||||||
export const tagSectionSeparator = '--'
|
export const tagSectionSeparator = '--'
|
||||||
|
export const enableTestsLocally = true
|
|
@ -6,8 +6,7 @@ import {tagSectionSeparator} from "./configs.mjs";
|
||||||
/**
|
/**
|
||||||
* finds patterns for file name
|
* finds patterns for file name
|
||||||
*/
|
*/
|
||||||
export default class finders{
|
export default class finders {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
patternsFiles = {
|
patternsFiles = {
|
||||||
|
@ -17,18 +16,28 @@ export default class finders{
|
||||||
'screenshot': /^Screenshot/i, // Screenshot 2023-06-15 at 15-26-04 Instance Panoramax OSM-FR.png
|
'screenshot': /^Screenshot/i, // Screenshot 2023-06-15 at 15-26-04 Instance Panoramax OSM-FR.png
|
||||||
}
|
}
|
||||||
|
|
||||||
static findScreenshot (inputString) {
|
static findScreenshot(inputString) {
|
||||||
return inputString.match(/screenshot/i) || inputString.match(/capture d'écran/i)
|
return inputString.match(/screenshot/i) || inputString.match(/capture d'écran/i)
|
||||||
}
|
}
|
||||||
|
|
||||||
static findFormattedDate(filepath) {
|
static findFormattedDate(filepath) {
|
||||||
let found = filepath.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/ig)
|
let match = filepath.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/ig)
|
||||||
console.log('found', found)
|
// console.log('match findFormattedDate', match)
|
||||||
return found
|
let result = ''
|
||||||
|
if (match && match[0]) {
|
||||||
|
result = match[0]
|
||||||
}
|
}
|
||||||
static findFileExtension (inputString) {
|
return result
|
||||||
let match = inputString.match(/\.\w{3,4}$/i)
|
}
|
||||||
return match
|
|
||||||
|
static findFileExtension(inputString) {
|
||||||
|
let result = inputString.match(/\.\w{3,4}$/i)
|
||||||
|
// console.log('match findFileExtension', match)
|
||||||
|
// let result = ''
|
||||||
|
// if (match && match[0]) {
|
||||||
|
// result = match[0]
|
||||||
|
// }
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,7 @@ import finders from './finders.mjs'
|
||||||
// })
|
// })
|
||||||
import exifr from 'exifr'
|
import exifr from 'exifr'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import {tagSectionSeparator, tagSeparator} from "./configs.mjs";
|
import {tagSectionSeparator, tagSeparator, enableTestsLocally} from "./configs.mjs";
|
||||||
|
|
||||||
const pathFolder = '/home/poule/encrypted/stockage-syncable/photos/a_dispatcher/tout'
|
const pathFolder = '/home/poule/encrypted/stockage-syncable/photos/a_dispatcher/tout'
|
||||||
const sortingFolder = '/home/poule/encrypted/stockage-syncable/photos/a_dispatcher'
|
const sortingFolder = '/home/poule/encrypted/stockage-syncable/photos/a_dispatcher'
|
||||||
|
@ -125,7 +125,7 @@ function renameFile(originalFileName, fileMixedNewName) {
|
||||||
// let list = getDirectories(pathFolder)
|
// let list = getDirectories(pathFolder)
|
||||||
// console.log('list', list)
|
// console.log('list', list)
|
||||||
|
|
||||||
let originalFileName = '2023-06-23T08.55.05.jpg'
|
let originalFileName = '2015-04-30T09.09.02 -- scan papier.jpg'
|
||||||
let formattedDatePIMBefore = finders.findFormattedDate(originalFileName)
|
let formattedDatePIMBefore = finders.findFormattedDate(originalFileName)
|
||||||
console.log('formattedDatePIMBefore', formattedDatePIMBefore)
|
console.log('formattedDatePIMBefore', formattedDatePIMBefore)
|
||||||
|
|
||||||
|
@ -239,16 +239,33 @@ TestScreenShotIsFoundAndRenamed()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function TestDateIsDetectedInFileName() {
|
function TestTagsAreDetectedInFileName() {
|
||||||
|
let mockFileName = '2023-06-15T10:11:12 -- screeenshot festival.png'
|
||||||
|
let expectedResult = ['screeenshot', 'festival']
|
||||||
|
let found = findTagSectionInString(mockFileName)
|
||||||
|
if (found === expectedResult) {
|
||||||
|
console.info('Succès')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function TestFindFormattedDate() {
|
||||||
let mockFileName = 'Capture d\'écran 2023-06-15T10:11:12.png'
|
let mockFileName = 'Capture d\'écran 2023-06-15T10:11:12.png'
|
||||||
let expectedFileNameAfterRename = '2023-06-15T10:11:12 -- screeenshot.png'
|
let expectedResult = '2023-06-15T10:11:12'
|
||||||
let foundDate = finders.findFormattedDate(mockFileName)
|
let found = finders.findFormattedDate(mockFileName)
|
||||||
console.log('foundDate', foundDate)
|
console.log('foundDate', found, expectedResult)
|
||||||
|
console.log('foundDate', found)
|
||||||
|
if (found === expectedResult) {
|
||||||
|
console.info('Succès')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// run tests
|
// run tests
|
||||||
TestDateIsDetectedInFileName()
|
if (enableTestsLocally) {
|
||||||
|
|
||||||
|
TestTagsAreDetectedInFileName()
|
||||||
|
TestFindFormattedDate()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
----------------------- parties non réalisées -----------------------
|
----------------------- parties non réalisées -----------------------
|
||||||
|
|
Loading…
Reference in New Issue