forked from bsthomsen/adonis-auditable
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstructions.js
35 lines (31 loc) · 860 Bytes
/
instructions.js
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
"use strict";
const path = require("path");
async function copyAuditMigration (cli) {
try {
const migrationsFile = cli.helpers.migrationsPath(
`${new Date().getTime()}_audit.js`);
await cli.copy(
path.join(__dirname, "templates", "AuditSchema.js"),
path.join(migrationsFile),
);
cli.command.completed("create",
migrationsFile.replace(cli.helpers.appRoot(), "").replace(path.sep, ""));
} catch (error) {
console.log(error);
}
}
async function copyAuditModel (cli) {
try {
await cli.copy(
path.join(__dirname, "templates", "Audit.js"),
path.join(cli.appDir, "Models/Audit.js"),
);
cli.command.completed("create", "Models/Audit.js");
} catch (error) {
console.log(error);
}
}
module.exports = async (cli) => {
await copyAuditModel(cli);
await copyAuditMigration(cli);
};