Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit 5c913b4

Browse files
committed
auto commit
1 parent e7f9f3f commit 5c913b4

9 files changed

Lines changed: 84 additions & 82 deletions

File tree

.scripty/scripts.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"scripts": {
4+
"default": {
5+
"name": "default",
6+
"run": {
7+
"type": "default",
8+
"command": "echo \"hello\""
9+
}
10+
}
11+
}
12+
}

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# This Package is un-working, please wait for a new update!
21
# EXScript
32

43
A simply overloaded "npm run"!
@@ -14,7 +13,7 @@ npm i -g exscript
1413
[] = optional, <> = required
1514

1615
#### Editing Scripts
17-
$Windows_HOMEDIR/.scripty/scripts.json is where we store scripts.
16+
$NODE_Global_Pacakages/exscript/.scripty/scripts.json is where we store scripts.
1817

1918
```
2019
exscript config [-e]
@@ -34,6 +33,4 @@ exscript reload
3433

3534
# ToDo
3635

37-
- [ ] Create Config V2 with script types
38-
- [ ] Fix Config reload broken
39-
- [ ] Cross OS Compatibility (currently written for windows)
36+
[Moved to Repo > Projects > Roadmap > To Do](https://github.com/theexproject/cli/projects/1#column-14231003)

bin/app.js

Lines changed: 41 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
const figlet = require('figlet');
33
const pkg = require('../package.json');
44
const os = require("os");
5+
const fs = require("fs");
56
const { exec } = require("child_process")
6-
var configdir = require("path").join(os.homedir() + "/.scripty");
7+
var configdir = require("path").join(process.cwd() + "/.scripty/");
78
const path = require('path');
89
const program = require('commander');
10+
const { join } = require('path');
911
program.version(pkg.version)
1012

1113
class app {
@@ -17,103 +19,68 @@ class app {
1719

1820
constructor(args) {
1921
this.args = args;
22+
if(!fs.existsSync(join(configdir, "scripts.json"))) {
23+
this.configurate().then(() => {
24+
this.config = require(join(configdir + 'scripts.json'))
25+
})
26+
} else {
27+
this.config = require(join(configdir + 'scripts.json'))
28+
}
2029
}
2130

2231
async start() {
2332
console.log(figlet.textSync("exscript", "Big Money-ne"));
24-
console.log(`\n\n\tversion: ${pkg.version}`);
25-
await this.configurate();
26-
var config = this.config
27-
program.option("-r, --run", "run a script", "default").action((name) => {
28-
if(config.scripts[name.run]) {
29-
var x = config.scripts[name.run]
33+
console.log(`\n\nversion: ${pkg.version}`);
34+
process.on("beforeExit", () => {
35+
fs.writeFile(join(configdir, "scripts.json"), JSON.stringify(require("./templates/scripts.json"), null, 4), () => {
36+
this.config = require(join(configdir + 'scripts.json'))
37+
})
38+
})
39+
program.command("run <name>").description("run a script").action((name) => {
40+
if(!name) return;
41+
console.log(`running`, name)
42+
if (this.config.scripts[name]) {
43+
var x = this.config.scripts[name]
3044
this.sh(x.run.command).then((put) => {
31-
if(put.stderr != '') {
32-
console.log(stderr)
45+
if (put.stderr != '') {
46+
console.log(stderr)
47+
process.exit()
3348
} else {
3449
console.log(put.stdout)
50+
process.exit()
3551
}
3652
})
53+
} else {
54+
console.log("Not Found")
55+
process.exit()
3756
}
3857
})
3958

40-
program.command("config").option("-e, --explorer", "open in explorer").description("opens config").action((opts) => {
41-
if(!opts.explorer) {
42-
this.sh(`notepad ${path.join(configdir, "scripts.json")}`).then(console.log("done"))
59+
program.command("this.config").option("-e, --explorer", "open in explorer").description("opens this.config").action((opts) => {
60+
if (!opts.explorer) {
61+
this.sh(`notepad ${path.join(this.configdir, "scripts.json")}`).then(console.log("done"))
4362
} else {
44-
this.sh(`explorer ${path.join(configdir)}`).then(console.log("done"))
63+
this.sh(`explorer ${path.join(this.configdir)}`).then(console.log("done"))
4564
}
4665
})
4766

48-
program.command("reload").description("reload config").action(() => {
49-
this.configurate()
67+
program.command("reload").description("reload this.config").action(() => {
68+
this.configurate().then(() => {
69+
process.exit();
70+
})
5071
})
5172

5273
program.parse(this.args);
5374
}
5475

5576
async configurate() {
56-
var config;
57-
console.log('owo');
58-
const fs = require("fs");
59-
if (!fs.existsSync(configdir)) {
60-
fs.mkdirSync(configdir, (err) => {
61-
if (err) {
62-
throw err;
63-
} else {
64-
if (!fs.existsSync(path.join(configdir, 'scripts.json'))) {
65-
fs.writeFileSync(path.join(configdir, 'scripts.json'), JSON.stringify({
66-
"version": 1,
67-
"scripts": {
68-
"default": {
69-
"name": "default",
70-
"run": {
71-
"type": "default",
72-
"command": "echo \"hello\""
73-
}
74-
}
75-
}
76-
}), (err) => {
77-
if (err) {
78-
throw err;
79-
} else {
80-
console.log("Saved first Config!")
81-
}
82-
})
83-
}
84-
}
77+
try {
78+
this.config = require(join(configdir + 'scripts.json'))
79+
} catch (e) {
80+
fs.writeFile(join(configdir, "scripts.json"), JSON.stringify(require("./templates/scripts.json"), null, 4), () => {
81+
this.config = require(join(configdir + 'scripts.json'))
8582
})
86-
} else {
87-
if (!fs.existsSync(path.join(configdir, 'scripts.json'))) {
88-
fs.writeFileSync(path.join(configdir, 'scripts.json'), JSON.stringify({
89-
"version": 1,
90-
"scripts": {
91-
"default": {
92-
"name": "default",
93-
"run": {
94-
"type": "default",
95-
"command": "echo \"hello\""
96-
}
97-
}
98-
}
99-
}), (err) => {
100-
if (err) {
101-
throw err;
102-
} else {
103-
console.log("Saved first Config!")
104-
}
105-
})
106-
} else {
107-
fs.readFileSync(path.join(configdir, 'scripts.json'), (err, data) => {
108-
if (err) {
109-
throw err
110-
} else {
111-
config = JSON.parse(data)
112-
}
113-
})
114-
}
11583
}
116-
this.config = config;
11784
}
11885

11986
async sh(cmd) {

bin/exsr.js

Whitespace-only changes.

bin/templates/scripts.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"scripts": {
4+
"default": {
5+
"name": "default",
6+
"run": {
7+
"type": "default",
8+
"command": "echo \"hello\""
9+
}
10+
}
11+
}
12+
}

exsr.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// soon:tm:

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "exscript",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "Advanced script saving system built on Node.js",
55
"main": "index.js",
66
"scripts": {
77
"test": "nodemon index.js -e js",
88
"git:push": "git add . && git commit -m \"auto commit\" && git push",
99
"npm:publish": "yarn publish",
10-
"bundle": "npm run git:push && npm run npm:publish"
10+
"bundle": "npm run git:push && npm run npm:publish",
11+
"loop": "npm run loop"
1112
},
1213
"repository": {
1314
"type": "git",

scripts.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"scripts": {
4+
"default": {
5+
"name": "default",
6+
"run": {
7+
"type": "default",
8+
"command": "echo \"hello\""
9+
}
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)