Skip to content

Added eslint \w airbnb config, editorconfig and gitignore for node app #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
51 changes: 51 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
root: true
extends:
- standard
- airbnb-base
env:
es6: true
node: true
rules:
no-useless-escape: off
no-param-reassign: off
prettier/prettier: off
prefer-rest-params: off
no-underscore-dangle: off
no-use-before-define: off
unicorn/filename-case: off
class-methods-use-this: off
import/no-default-export: off
curly:
- error
comma-dangle:
- error
- always-multiline
id-length:
- error
-
min: 2
exceptions:
- i
- x
- y
- e
id-match:
- error
- "^(([A-Za-z0-9]+){2,})|([A-Z][A-Z_0-9]+)$"
-
properties: false
onlyDeclarations: true
indent:
- error
- 2
-
SwitchCase: 1
quotes:
- error
- single
semi:
- error
- always
space-before-function-paren:
- error
- always
64 changes: 64 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
bower_components/
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# VSCode
.vscode/

# dotenv environment variables file
.env

*.traineddata
files/

package-lock.json
60 changes: 31 additions & 29 deletions configure.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const fs = require('fs');
const prompt = require('prompt');
const { execSync } = require('child_process');
const processes = require('./processes.json');

const dataStringify = JSON.stringify(processes);
const dataParsed = JSON.parse(dataStringify);

const {exec, execSync, execFileSync} = require('child_process');
prompt.colors = false;

process.stdin.resume(); //so the program will not close instantly
process.stdin.resume(); // so the program will not close instantly

function exitHandler(options, err) {
function exitHandler (options, err) {
try {
if (err) {
process.kill(process.pid);
Expand All @@ -20,42 +21,43 @@ function exitHandler(options, err) {
} else if (options.pid) {
process.kill(process.pid);
}
} catch (err) {
console.log(err);
} catch (error) {
console.log(error);
}
}

//catches ctrl+c and stop.sh events
process.on('SIGINT', exitHandler.bind(null, {exit: true}));
// catches ctrl+c and stop.sh events
process.on('SIGINT', exitHandler.bind(null, { exit: true }));

//catches "kill pid" (for example: nodemon restart)
process.on('SIGUSR1', exitHandler.bind(null, {pid: true}));
process.on('SIGUSR2', exitHandler.bind(null, {pid: true}));
// catches "kill pid" (for example: nodemon restart)
process.on('SIGUSR1', exitHandler.bind(null, { pid: true }));
process.on('SIGUSR2', exitHandler.bind(null, { pid: true }));

//catches uncaught exceptions
// catches uncaught exceptions
process.on('uncaughtException', exitHandler.bind(null, {
exit: true,
reason: 'uncaughtException'
reason: 'uncaughtException',
}));

main();

async function main() {
try {
var cp = execSync('cp processes.json processes_backup.json');
async function main () {
try {
execSync('cp processes.json processes_backup.json');
let newName;

if (process.env.WICKRIO_BOT_NAME !== undefined) {
var newName = "WickrIO-File-Bot_" + process.env.WICKRIO_BOT_NAME;
} else {
var newName = "WickrIO-File-Bot";
}
if (process.env.WICKRIO_BOT_NAME !== undefined) {
newName = `WickrIO-File-Bot_${process.env.WICKRIO_BOT_NAME}`;
} else {
newName = 'WickrIO-File-Bot';
}

//var assign = Object.assign(dataParsed.apps[0].name, newName);
dataParsed.apps[0].name = newName;
// var assign = Object.assign(dataParsed.apps[0].name, newName);
dataParsed.apps[0].name = newName;

var ps = fs.writeFileSync('./processes.json', JSON.stringify(dataParsed, null, 2));
} catch (err) {
console.log(err);
}
process.exit();
fs.writeFileSync('./processes.json', JSON.stringify(dataParsed, null, 2));
} catch (err) {
console.log(err);
}
process.exit();
}

main();
Loading