11'use strict'
22
33const execa = require ( 'execa' )
4+ const pathExists = require ( 'path-exists' )
5+ const util = require ( 'util' )
46const xattr = require ( 'fs-xattr' )
5- const cpFile = require ( 'cp-file' )
6- const alloc = require ( 'buffer-alloc' )
77
88exports . sh = function ( prog , args , cb ) {
9- execa ( prog , args ) . then ( function ( result ) {
10- setImmediate ( cb , null , result )
11- } ) . catch ( function ( err ) {
12- setImmediate ( cb , err )
13- } )
14- }
15-
16- exports . cp = function ( source , target , cb ) {
17- cpFile ( source , target ) . then ( function ( ) {
18- setImmediate ( cb , null )
19- } ) . catch ( function ( err ) {
20- setImmediate ( cb , err )
21- } )
9+ util . callbackify ( ( ) => execa ( prog , args ) ) ( cb )
2210}
2311
2412exports . dusm = function ( path , cb ) {
25- exports . sh ( 'du' , [ '-sm' , path ] , function ( err , res ) {
13+ exports . sh ( 'du' , [ '-sm' , path ] , ( err , res ) => {
2614 if ( err ) return cb ( err )
2715
2816 if ( res . stderr . length > 0 ) {
@@ -44,16 +32,20 @@ exports.tiffutil = function (a, b, out, cb) {
4432}
4533
4634exports . seticonflag = function ( path , cb ) {
47- const buf = alloc ( 32 )
35+ const buf = Buffer . alloc ( 32 )
4836 buf . writeUInt8 ( 4 , 8 )
49- xattr . set ( path , 'com.apple.FinderInfo' , buf , cb )
37+ util . callbackify ( ( ) => xattr . set ( path , 'com.apple.FinderInfo' , buf ) ) ( cb )
5038}
5139
5240exports . codesign = function ( identity , identifier , path , cb ) {
53- var args = [ '--verbose' , '--sign' , identity ]
41+ let args = [ '--verbose' , '--sign' , identity ]
5442 if ( identifier ) {
5543 args . push ( '--identifier' , identifier )
5644 }
5745 args . push ( path )
58- exports . sh ( 'codesign' , args , function ( err ) { cb ( err ) } )
46+ exports . sh ( 'codesign' , args , ( err ) => cb ( err ) )
47+ }
48+
49+ exports . pathExists = function ( path , cb ) {
50+ util . callbackify ( ( ) => pathExists ( path ) ) ( cb )
5951}
0 commit comments