@makano/rew 1.2.65 → 1.2.66

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  const path = require('path');
2
2
 
3
- const CONFIG_PATH = path.resolve(process.env.HOME, '.local/share/rew');
3
+ const CONFIG_PATH = path.resolve(process.env.HOME || process.env.USERPROFILE, '.local/share/rew');
4
4
  module.exports.CONFIG_PATH = CONFIG_PATH;
@@ -12,4 +12,18 @@ module.exports.USING_DEFAULT = {
12
12
  DECORATORS: {
13
13
  use: (options) => options.decorators = true
14
14
  }
15
+ }
16
+
17
+ module.exports.Usage = class Usage {
18
+ name = "null";
19
+ trigger = () => {}
20
+
21
+ constructor(name, trigger){
22
+ this.name = name;
23
+ this.trigger = trigger;
24
+ }
25
+
26
+ create(name, trigger){
27
+ return new Usage(name, trigger);
28
+ }
15
29
  }
@@ -7,7 +7,7 @@ const fsLib = require("../functions/fs");
7
7
  const pathLib = require("../functions/path");
8
8
  const execLib = require("../functions/exec");
9
9
  const { findAppInfo } = require("../misc/findAppInfo");
10
- const { USING_DEFAULT } = require("../const/usage");
10
+ const { USING_DEFAULT, Usage } = require("../const/usage");
11
11
 
12
12
  let mainFile = "";
13
13
  const isMainFile = (filepath) => filepath == mainFile;
@@ -45,6 +45,7 @@ module.exports.prepareContext = function (
45
45
  ...pathLib(filepath),
46
46
  ...execLib(filepath),
47
47
  ...custom_context,
48
+ Usage
48
49
  };
49
50
  }
50
51
  if (!context.process)
@@ -98,6 +99,8 @@ module.exports.prepareContext = function (
98
99
  if(USING_DEFAULT[name].param) {
99
100
  context.__using__[name] = USING_DEFAULT[name].param(...params);
100
101
  }
102
+ } else if(name instanceof Usage) {
103
+ context.__using__[name.name] = name.trigger(...params) || true;
101
104
  } else {
102
105
  context.__using__[name] = params.length ? params.length > 1 ? [...params] : params : true;
103
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.65",
3
+ "version": "1.2.66",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {