-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.test.js
More file actions
48 lines (42 loc) · 1.46 KB
/
Copy pathinit.test.js
File metadata and controls
48 lines (42 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as assert from 'assert';
import { readFileSync } from 'fs';
import { writeFile, mkdir, access } from 'fs/promises';
import path from 'path';
import rimraf from 'rimraf';
import 'colors';
import cli from './cliTester.js';
import { errors } from './../src/errors/index.js';
describe('Testing CLI', function () {
describe('Initialization', function () {
it('When init is run it should create new hlambda config folder', async function () {
const testingFolder = 'temp/automatic-test';
const cwd = path.resolve(process.cwd());
const initFilePath = path.resolve(cwd, testingFolder);
const result = await cli(['init', testingFolder], '.');
// Check if the new folder is present
const folderExists = await access(initFilePath)
.then((result) => {
return true;
})
.catch((error) => {
// console.log(error);
// throw new Error(errors.ERROR_FS_READ_ERROR);
return false;
});
assert.equal(folderExists, true);
// Clear path
if (
typeof initFilePath === 'string' &&
initFilePath !== '' &&
initFilePath !== '/' &&
initFilePath !== '/*'
) {
// Sanity check !!!
// console.log(`Removing everything inside ${initFilePath}`.red);
rimraf.sync(`${initFilePath}`); // Please be careful...
} else {
throw new Error(errors.ERROR_DANGEROUS_SANITY_CHECK_DID_NOT_PASS);
}
});
});
});