Skip to content

Commit

Permalink
fix(#56): build cache for published packages
Browse files Browse the repository at this point in the history
  • Loading branch information
markhughes committed Mar 14, 2022
1 parent 24ba1bf commit 4be1efa
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
"node": ">= 12.10.0"
},
"scripts": {
"build": "DROPPY_CACHE_PATH=$PWD/packages/cli/dist/cache.json lerna run --stream build --",
"start": "lerna run --stream start --",
"bootstrap": "lerna bootstrap",
"lint": "eslint packages",
"test": "jest",
"postinstall": "husky install && yarn bootstrap",
"pub:canary": "lerna publish --c",
"pub": "lerna publish && git push"
"pub": "yarn build && lerna publish && git push"
},
"resolutions": {
"hosted-git-info": "^4.0.2",
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/bin/droppy
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!/usr/bin/env node

const {realpathSync, existsSync} = require("fs");
const path = require("path");

const cachePath = realpathSync(path.join(__dirname, "..", "dist", "cache.json"));
if (existsSync(cachePath)) {
process.env.DROPPY_CACHE_PATH = cachePath;
}

require("../lib/cli");
16 changes: 8 additions & 8 deletions packages/cli/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ if (argv.daemon || argv.d) {
require("daemonize-process")();
}

if (argv._[0] === "build") {
console.info("Building resources ...");
resources.build(err => {
console.info(err || "Resources built successfully");
process.exit(err ? 1 : 0);
});
}

if (argv.configdir || argv.filesdir || argv.c || argv.f) {
paths.seed(argv.configdir || argv.c, argv.filesdir || argv.f);
}
Expand Down Expand Up @@ -131,6 +123,14 @@ switch (cmd) {
break;
}

case "build":
console.info("Building resources ...");
resources.build(err => {
console.info(err || "Resources built successfully");
process.exit(err ? 1 : 0);
});
break;

case "version":
console.info(pkg.version);
break;
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"url": "git+https://github.com/droppyjs/droppy.git"
},
"scripts": {
"start": "node ./lib/cli.js start"
"start": "node ./lib/cli.js start",
"build": "node ./lib/cli.js build"
},
"bugs": {
"url": "https://github.com/droppyjs/droppy/issues"
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/services/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const utils = require("./utils.js");

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

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

Expand Down

0 comments on commit 4be1efa

Please sign in to comment.