File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ var fs = require ( 'fs' ) ;
2
+ var exec = require ( 'child_process' ) . exec ;
3
+
4
+ exports . execCmd = function ( cmd , cb ) {
5
+ exec ( cmd , function ( err ) {
6
+ if ( err ) throw err ;
7
+ if ( cb ) cb ( ) ;
8
+ } )
9
+ . stdout . pipe ( process . stdout ) ;
10
+ } ;
11
+
12
+ exports . writeFile = function ( filePath , content , cb ) {
13
+ fs . writeFile ( filePath , content , function ( err ) {
14
+ if ( err ) throw err ;
15
+ if ( cb ) cb ( ) ;
16
+ } ) ;
17
+ } ;
18
+
19
+ exports . doesDirExist = function ( dirPath ) {
20
+ try {
21
+ if ( fs . statSync ( dirPath ) . isDirectory ( ) ) return true ;
22
+ }
23
+ catch ( e ) {
24
+ return false ;
25
+ }
26
+
27
+ return false ;
28
+ } ;
29
+
30
+ exports . doesFileExist = function ( filePath ) {
31
+ try {
32
+ if ( fs . statSync ( filePath ) . isFile ( ) ) return true ;
33
+ }
34
+ catch ( e ) {
35
+ return false ;
36
+ }
37
+
38
+ return false ;
39
+ } ;
40
+
41
+ exports . touch = function ( filePath ) {
42
+ fs . closeSync ( fs . openSync ( filePath , 'w' ) ) ;
43
+ } ;
44
+
45
+ exports . throwOnError = function ( err ) {
46
+ if ( err ) throw err ;
47
+ } ;
You can’t perform that action at this time.
0 commit comments