Skip to content

Commit 86c0320

Browse files
authored
Feature copyIfNotExists to Utility Class (#18)
Feature `copyIfNotExists` to `Utility Class`
2 parents 96014dc + 4128bd0 commit 86c0320

File tree

4 files changed

+32
-35
lines changed

4 files changed

+32
-35
lines changed

.github/workflows/running.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Jest Test
1+
name: Initialize TLighthouse and Test using Jest
22

33
on:
44
pull_request:
@@ -24,4 +24,25 @@ jobs:
2424
run: npm ci
2525

2626
- name: Test with Jest
27-
run: npm test
27+
run: npm test
28+
29+
running:
30+
name: Install and Run
31+
32+
runs-on: ubuntu-latest
33+
34+
strategy:
35+
matrix:
36+
node-version: [16.x, 18.x, 20.x]
37+
38+
steps:
39+
- uses: actions/checkout@v3
40+
41+
- name: Set up Chrome
42+
uses: browser-actions/setup-chrome@v1
43+
44+
- name: Install
45+
run: npm ci
46+
47+
- name: Running the program
48+
run: npm start

setup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { existsSync, copyFileSync } from 'fs'
1+
import { copyIfNotExists } from "./src/lib/utilities.class.js";
22

3-
if (!existsSync('./src/urlList.class.js')) copyFileSync('./src/urlList.class.example', './src/urlList.class.js')
3+
copyIfNotExists('./src/urlList.class.js', './src/urlList.class.example')

src/lib/utilities.class.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { existsSync, copyFileSync } from 'fs'
2+
13
class Utility {
24
LoggerType = {
35
'info': "Info",
@@ -22,6 +24,10 @@ class Utility {
2224
if (condition) console.log(`${typeFormatted}`, text)
2325
}
2426

27+
copyIfNotExists = (location, source) => {
28+
if (!existsSync(location)) copyFileSync(source, location)
29+
}
30+
2531
#isArrayEmpty = (data = []) => {
2632
return (data === undefined || data.length === 0) ? false : true
2733
}
@@ -34,4 +40,4 @@ class Utility {
3440
}
3541

3642
export default new Utility()
37-
export const { Logger, LoggerType } = new Utility()
43+
export const { Logger, LoggerType, copyIfNotExists } = new Utility()

0 commit comments

Comments
 (0)