Skip to content

Commit

Permalink
Change the structure of the application
Browse files Browse the repository at this point in the history
  • Loading branch information
mkinitcpio committed Jun 6, 2018
1 parent 6953689 commit 72b485b
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 35 deletions.
34 changes: 0 additions & 34 deletions main.js

This file was deleted.

2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ notInstalled="nodejs is not installed."

if [ -x "$(command -v node)" ];
then
node main.js
node ./src/main.js
else
echo $notInstalled
exit 1
Expand Down
15 changes: 15 additions & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { spawn } = require('child_process');

const installDependencies = () => new Promise((resolve, reject) => {
const npm = spawn('npm', ['i']);
npm.on('error', reject);
npm.on('close', resolve);
});

const unpackSkypeApplication = () => new Promise((resolve, reject) => {
const npm = spawn('npm', ['run', 'extract']);
npm.stdout.on('error', reject);
npm.stdout.on('close', resolve);
});

module.exports = { installDependencies, unpackSkypeApplication };
27 changes: 27 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const fs = require('fs');
const paths = require('./paths.json');

const {
unpackSkypeApplication,
installDependencies
} = require('./helpers');

const main = async () => {
const isExist = path => fs.existsSync(path);
const pathToSkype = paths.skype;

if (isExist(pathToSkype)) {

console.log('Installing dependencies...');
await installDependencies();
console.log('The installation is complete!\n----');

console.log('Unpacking skype packages...');
await unpackSkypeApplication();
console.log('Unpacking is complete!');
} else {
throw new Error("'Skype for linux' applicaton does not exist");
}
}

main();
File renamed without changes.

0 comments on commit 72b485b

Please sign in to comment.