Skip to content

Commit

Permalink
feat: installdir option
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed Dec 13, 2018
1 parent 4507065 commit c217c2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/npm-pkgbuild-cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { promises } = require("fs");
program
.description("create arch linux package from npm")
.version(version)
.option("-i <dir>")
.option("-w <dir>")
.action(async (args, options, logger) => {
if (options.w !== undefined) {
Expand All @@ -17,7 +18,7 @@ program

const dest = createWriteStream(join(wd, "PKGBUILD"));

await npm2pkgbuild(process.cwd(), dest);
await npm2pkgbuild(process.cwd(), dest, { installdir : options.i });

const r = await execa("makepkg", ["-f"], { cwd: wd });
console.log(r.stderr);
Expand Down
7 changes: 5 additions & 2 deletions src/npm-pkgbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { promisify } from 'util';
import { finished } from 'stream';
import fs from "fs";

export async function npm2pkgbuild(dir, out) {
export async function npm2pkgbuild(dir, out, options = {}) {
const installdir = options.installdir || '/';

const pkgFile = join(dir, "package.json");
const pkg = JSON.parse(
await fs.promises.readFile(pkgFile, { encoding: "utf-8" })
Expand Down Expand Up @@ -94,7 +96,8 @@ build() {
}
package() {
(cd "\${srcdir}/${pkg.name}";tar cf - * )|(cd "\${pkgdir}";tar xf - )
mkdir -p "\${pkgdir}/${installdir}"
(cd "\${srcdir}/${pkg.name}";tar cf - * )|(cd "\${pkgdir}/${installdir}";tar xf - )
}
`
);
Expand Down

0 comments on commit c217c2d

Please sign in to comment.