Skip to content

Commit

Permalink
Commando programming continues...
Browse files Browse the repository at this point in the history
  • Loading branch information
canibanoglu committed Nov 13, 2019
1 parent 37feff1 commit 853fe5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
8 changes: 5 additions & 3 deletions scripts/postinstall.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {wrapBinaryCommands} from "./wrapBinaryCommands";
#!/usr/bin/env node
import { wrapBinaryCommands } from "./wrapBinaryCommands";

Promise.all([wrapBinaryCommands()]).then(() => {
console.log('Done settin up');
});
console.log("Done settin up");
});

20 changes: 10 additions & 10 deletions scripts/wrapBinaryCommands.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const packageInfo = require('../package.json');
const fs = require('fs').promises;
const path = require('path');
#!/usr/bin/env node
const packageInfo = require("../package.json");
const fs = require("fs").promises;
const path = require("path");

const WRAPPER_CONTENT = fileName => `#!/usr/bin/env node
const path = require('path');
Expand All @@ -9,22 +10,21 @@ console.log(module.path);
module.exports = require(path.join(module.path, '..', '${fileName}'));
`;


export async function wrapBinaryCommands() {
await fs.mkdir(path.join('./bin/.build'), { recursive: true });
await fs.mkdir(path.join("./bin/.build"), { recursive: true });

const commands = packageInfo.bin;
const promises = Object.keys(commands).map(async cmd => {
const sourceName = commands[cmd].split('/')[3];
const filePath = path.join('./bin/.build/', sourceName);
const fileHandle = await fs.open(filePath, 'w');
const sourceName = commands[cmd].split("/")[3];
const filePath = path.join("./bin/.build/", sourceName);
const fileHandle = await fs.open(filePath, "w");
return fileHandle.writeFile(WRAPPER_CONTENT(sourceName)).then(() => {
fileHandle.close();
});
});

console.info('Creating wrapper bin files under ./bin/.build/');
console.info("Creating wrapper bin files under ./bin/.build/");
Promise.all(promises).then(() => {
console.info('Successfully finished wrapping binary commands');
console.info("Successfully finished wrapping binary commands");
});
}

0 comments on commit 853fe5f

Please sign in to comment.