mirror of https://github.com/lukechilds/rollup.git
Rich Harris
9 years ago
11 changed files with 47 additions and 29 deletions
@ -0,0 +1,13 @@ |
|||
export function readdirSync () { |
|||
throw new Error( 'Cannot use fs.readdirSync inside browser' ); |
|||
} |
|||
|
|||
export function readFileSync () { |
|||
throw new Error( 'Cannot use fs.readFileSync inside browser' ); |
|||
} |
|||
|
|||
export function writeFile () { |
|||
throw new Error( 'Cannot use fs.writeFile inside browser' ); |
|||
} |
|||
|
|||
export const Promise = window.Promise; |
@ -0,0 +1 @@ |
|||
export default window.Promise; |
@ -1,17 +0,0 @@ |
|||
export function readdirSync () { |
|||
throw new Error( 'Cannot use sander.readdirSync inside browser' ); |
|||
} |
|||
|
|||
export function readFile () { |
|||
throw new Error( 'Cannot use sander.readFile inside browser' ); |
|||
} |
|||
|
|||
export function readFileSync () { |
|||
throw new Error( 'Cannot use sander.readFileSync inside browser' ); |
|||
} |
|||
|
|||
export function writeFile () { |
|||
throw new Error( 'Cannot use sander.writeFile inside browser' ); |
|||
} |
|||
|
|||
export const Promise = window.Promise; |
@ -0,0 +1,17 @@ |
|||
import Promise from 'es6-promise/lib/es6-promise/promise'; |
|||
import * as fs from 'fs'; |
|||
|
|||
export function writeFile ( dest, data ) { |
|||
return new Promise( ( fulfil, reject ) => { |
|||
fs.writeFile( dest, data, err => { |
|||
if ( err ) { |
|||
reject( err ); |
|||
} else { |
|||
fulfil(); |
|||
} |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
export const readdirSync = fs.readdirSync; |
|||
export const readFileSync = fs.readFileSync; |
Loading…
Reference in new issue