Skip to content

Commit

Permalink
refactor: replaced runner.readDirectory by native fs.readdirSync API (
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaysinghs772 committed Apr 1, 2024
1 parent cfa3d7e commit 1e14301
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
7 changes: 4 additions & 3 deletions spec/build.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const assert = require('assert');
const runner = require('./runner');
const fs = require('fs');

describe('Run neu build command and its options', () => {
before(() => {
Expand All @@ -19,7 +20,7 @@ describe('Run neu build command and its options', () => {
describe('Test building binaries for supported platforms and resources.neu file', () => {
it('populates ./dist directory with binaries', async() => {
let output = runner.run('neu build');
const binaries = runner.readDirectory('./dist/test-app/');
const binaries = fs.readdirSync('./dist/test-app/');

assert.equal(output.error, null);
assert.equal(output.status, 0);
Expand All @@ -36,7 +37,7 @@ describe('Run neu build command and its options', () => {
});
it('creates & populates ./dist directory with binaries and portable ZIP bundle', async() => {
let output = runner.run('neu build --release');
const applicationBundle = runner.readDirectory('./dist/');
const applicationBundle = fs.readdirSync('./dist/');

assert.equal(output.error, null);
assert.equal(output.status, 0);
Expand All @@ -48,7 +49,7 @@ describe('Run neu build command and its options', () => {
it('copies the current snapshot of the Neutralinojs storage to the application bundle', async() => {
runner.run(' mkdir .storage') // .storage doesn't exist by default in the template
let output = runner.run('neu build --copy-storage');
const storageSnapshot = runner.readDirectory('./dist/test-app');
const storageSnapshot = fs.readdirSync('./dist/test-app');

assert.equal(output.error, null);
assert.equal(output.status, 0);
Expand Down
15 changes: 0 additions & 15 deletions spec/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,6 @@ function cleanup() {
}
}

function readDirectory(path) {
let files = [];
try {
fs.readdirSync(path).forEach(file => {
files.push(file);
});
}
catch(err) {
// ignore
}

return files;
}

function updateVersions(binaryVersion, clientVersion) {
const file = 'neutralino.config.json';
const config = JSON.parse(fs.readFileSync(file));
Expand All @@ -61,7 +47,6 @@ function updateVersions(binaryVersion, clientVersion) {

module.exports = {
cleanup,
readDirectory,
updateVersions,
run
}

0 comments on commit 1e14301

Please sign in to comment.