Skip to content

Commit

Permalink
build: 3.0.0
Browse files Browse the repository at this point in the history
* build: 3.0.0
  • Loading branch information
CarlosCarmona authored Jan 8, 2021
1 parent ce34b22 commit fc3e27e
Show file tree
Hide file tree
Showing 9 changed files with 338 additions and 87 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
.gitignore
.prettierignore
LICENSE
*.sql
*.png
*.txt
TODO
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Runnerty Tech S.L.
Copyright (c) 2021 Runnerty Tech S.L.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,26 @@

### Installation:

Through NPM

```bash
npm i @runnerty/executor-mysql
```

You can also add modules to your project with [runnerty-cli]

```bash
npx runnerty-cli add @runnerty/executor-mysql
```

This command installs the module in your project, adds example configuration in your `config.json` and creates an example plan of use.

If you have installed [runnerty-cli] globally you can include the module with this command:

```bash
rty add @runnerty/executor-mysql
```

### Configuration:

Add in [config.json]:
Expand Down Expand Up @@ -203,4 +219,5 @@ For file upload you must indicate the path of the file to be loaded in the `loca
[david-badge]: https://david-dm.org/runnerty/executor-mysql.svg
[david-badge-url]: https://david-dm.org/runnerty/executor-mysql
[config.json]: http://docs.runnerty.io/config/
[runnerty-cli]: https://www.npmjs.com/package/runnerty-cli
[plan.json]: http://docs.runnerty.io/plan/
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const mysql = require('mysql2');
const Excel = require('exceljs');
const csv = require('fast-csv');
const fs = require('fs');
const fsp = require('fs').promises;

const loadSQLFile = global.libUtils.loadSQLFile;
const Execution = global.ExecutionClass;
const Executor = require('@runnerty/module-core').Executor;

class mysqlExecutor extends Execution {
class mysqlExecutor extends Executor {
constructor(process) {
super(process);
this.ended = false;
Expand Down Expand Up @@ -265,7 +265,13 @@ class mysqlExecutor extends Execution {
try {
if (!params.command) {
if (params.command_file) {
params.command = await loadSQLFile(params.command_file);
// Load SQL file:
try {
await fsp.access(params.command_file, fs.constants.F_OK | fs.constants.W_OK);
params.command = await fsp.readFile(params.command_file, 'utf8');
} catch (err) {
throw new Error(`Load SQLFile: ${err}`);
}
} else {
this.endOptions.end = 'error';
this.endOptions.messageLog = 'executeMysql dont have command or command_file';
Expand Down
Loading

0 comments on commit fc3e27e

Please sign in to comment.