8000 impl curry · TYPECASTINGSG/rpscript-api-open@f56ea34 · GitHub
[go: up one dir, main page]

Skip to content

Commit f56ea34

Browse files
committed
impl curry
1 parent b914ac9 commit f56ea34

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"dependencies": {
2626
"opn": "^5.3.0",
27-
"rpscript-interface": "^0.6.1"
27+
"rpscript-interface": "^0.6.2"
2828
},
2929
"devDependencies": {
3030
"@types/chai": "^4.1.4",

src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import opn from 'opn';
22
import {ChildProcess, execSync} from 'child_process';
3-
import {RpsContext,RpsModule,rpsAction} from 'rpscript-interface';
3+
import {RpsContext,RpsModule,rpsAction,R} from 'rpscript-interface';
44

55

66
/** Open a file or url in the user's preferred application.
@@ -28,8 +28,13 @@ export default class RPSOpen {
2828
*
2929
*/
3030
@rpsAction({verbName:'open'})
31-
open (ctx:RpsContext,opts:Object, filepath:string,preferredApp?:string) : Promise<ChildProcess|Buffer>{
32-
return opn(filepath,opts);
31+
open (ctx:RpsContext,opts:Object, filepath?:string) : Promise<ChildProcess|Buffer>|Function{
32+
if(!filepath){
33+
return function (filepath) {
34+
return opn(filepath,opts);
35+
}
36+
}
37+
else opn(filepath,opts);
3338
}
3439

3540
private childProcessOpen (filepath:string) :Buffer {

test/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ m.describe('Open', () => {
1010
let open = new RPSOpen;
1111

1212
await open.open(new RpsContext,{},"README.md");
13-
13+
1414
await open.open(new RpsContext,{},"https://www.google.com.sg");
15-
await open.open(new RpsContext,{app:'firefox'},"https://www.google.com.sg");
15+
16+
let firefox:any = await open.open(new RpsContext,{app:'firefox'});
17+
firefox("https://www.google.com.sg");
1618

1719
}).timeout(0);
1820

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"types":["node"],
1414
"target": "es2015",
1515
"module": "commonjs",
16+
"skipLibCheck": true,
1617
"declaration": true,
1718
"strict": false,
1819
"esModuleInterop": true,

0 commit comments

Comments
 (0)
0