Skip to content

Commit 4be1efa

Browse files
committed
fix(#56): build cache for published packages
1 parent 24ba1bf commit 4be1efa

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
"node": ">= 12.10.0"
1212
},
1313
"scripts": {
14+
"build": "DROPPY_CACHE_PATH=$PWD/packages/cli/dist/cache.json lerna run --stream build --",
1415
"start": "lerna run --stream start --",
1516
"bootstrap": "lerna bootstrap",
1617
"lint": "eslint packages",
1718
"test": "jest",
1819
"postinstall": "husky install && yarn bootstrap",
1920
"pub:canary": "lerna publish --c",
20-
"pub": "lerna publish && git push"
21+
"pub": "yarn build && lerna publish && git push"
2122
},
2223
"resolutions": {
2324
"hosted-git-info": "^4.0.2",

packages/cli/bin/droppy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
#!/usr/bin/env node
22

3+
const {realpathSync, existsSync} = require("fs");
4+
const path = require("path");
5+
6+
const cachePath = realpathSync(path.join(__dirname, "..", "dist", "cache.json"));
7+
if (existsSync(cachePath)) {
8+
process.env.DROPPY_CACHE_PATH = cachePath;
9+
}
10+
311
require("../lib/cli");

packages/cli/lib/cli.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ if (argv.daemon || argv.d) {
5454
require("daemonize-process")();
5555
}
5656

57-
if (argv._[0] === "build") {
58-
console.info("Building resources ...");
59-
resources.build(err => {
60-
console.info(err || "Resources built successfully");
61-
process.exit(err ? 1 : 0);
62-
});
63-
}
64-
6557
if (argv.configdir || argv.filesdir || argv.c || argv.f) {
6658
paths.seed(argv.configdir || argv.c, argv.filesdir || argv.f);
6759
}
@@ -131,6 +123,14 @@ switch (cmd) {
131123
break;
132124
}
133125

126+
case "build":
127+
console.info("Building resources ...");
128+
resources.build(err => {
129+
console.info(err || "Resources built successfully");
130+
process.exit(err ? 1 : 0);
131+
});
132+
break;
133+
134134
case "version":
135135
console.info(pkg.version);
136136
break;

packages/cli/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"url": "git+https://github.com/droppyjs/droppy.git"
4343
},
4444
"scripts": {
45-
"start": "node ./lib/cli.js start"
45+
"start": "node ./lib/cli.js start",
46+
"build": "node ./lib/cli.js build"
4647
},
4748
"bugs": {
4849
"url": "https://github.com/droppyjs/droppy/issues"

packages/server/lib/services/resources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const utils = require("./utils.js");
1616

1717
const themesPath = path.join(paths.client, "/node_modules/codemirror/theme");
1818
const modesPath = path.join(paths.client, "/node_modules/codemirror/mode");
19-
const cachePath = path.join(paths.homedir, "/.droppy/cache/cache.json");
19+
const cachePath = process.env.DROPPY_CACHE_PATH ?? path.join(paths.homedir, "/.droppy/cache/cache.json");
2020

2121
const pkg = require("../../package.json");
2222

0 commit comments

Comments
 (0)