Skip to content

Commit 128b04d

Browse files
committed
ci(yarn): added dist comamnd to yarn and a cross platform cp command
1 parent fc04316 commit 128b04d

3 files changed

Lines changed: 59 additions & 1 deletion

File tree

.github/cp.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const USAGE = "Usage: node cp.js [SOURCE_FILE] [DESTINATION_DIR]\n";
5+
6+
const args = process.argv.slice(2);
7+
8+
if(args.length != 2){
9+
console.error(USAGE);
10+
throw new SyntaxError();
11+
}
12+
const src = args[0];
13+
const dest = args[1];
14+
15+
if(src.includes("*") || dest.includes("*")){
16+
throw new SyntaxError("globbing is not supported");
17+
}
18+
19+
20+
21+
if(!(fs.existsSync(src) && fs.statSync(src).isFile())){
22+
throw new TypeError(`${src} is not a file`);
23+
}
24+
25+
if(!(fs.existsSync(dest) && fs.statSync(dest).isDirectory())){
26+
throw new TypeError(`${dest} is not a directory`);
27+
}
28+
29+
fs.copyFileSync(src, path.join(dest, path.basename(src)));

.github/mkdir.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fs = require('fs');
2+
3+
const WARNINGS_ON = true;
4+
5+
const USAGE = "Usage: node mkdir.js [DIR_NAME]\n";
6+
7+
const args = process.argv.slice(2);
8+
9+
if(args.length != 1){
10+
console.error(USAGE);
11+
throw new SyntaxError();
12+
}
13+
const dir = args[0];
14+
15+
if(dir.includes("*")){
16+
throw new SyntaxError("globbing is not supported");
17+
}
18+
19+
if(fs.existsSync(dir)){
20+
if(fs.statSync(dir).isFile()){
21+
throw new Error(`${dir} is a file`);
22+
}
23+
fs.statSync(dir).isDirectory() && WARNINGS_ON && console.warn(`${dir} already exists, doing nothing`);
24+
return;
25+
}
26+
27+
fs.mkdirSync(dir);

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
"license": "MIT",
88
"private": true,
99
"scripts": {
10+
"cp": "node .github/cp.js",
11+
"mkdir": "node .github/mkdir.js",
1012
"build": "yarn run tsc",
11-
"dev": "yarn build && node ./dist/test.js",
13+
"dist": "yarn build && yarn cp ./src/ProjectExport.d.ts dist",
1214
"test": "mocha"
1315
},
1416
"dependencies": {

0 commit comments

Comments
 (0)