mirror of https://github.com/lukechilds/rollup.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
685 B
32 lines
685 B
import Promise from 'es6-promise/lib/es6-promise/promise.js';
|
|
import * as fs from 'fs';
|
|
import { dirname } from './path.js';
|
|
|
|
function mkdirpath ( path ) {
|
|
const dir = dirname( path );
|
|
try {
|
|
fs.readdirSync( dir );
|
|
} catch ( err ) {
|
|
mkdirpath( dir );
|
|
fs.mkdirSync( dir );
|
|
}
|
|
}
|
|
|
|
export function writeFile ( dest, data ) {
|
|
return new Promise( ( fulfil, reject ) => {
|
|
mkdirpath( dest );
|
|
|
|
fs.writeFile( dest, data, err => {
|
|
if ( err ) {
|
|
reject( err );
|
|
} else {
|
|
fulfil();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
export const lstatSync = fs.lstatSync;
|
|
export const readdirSync = fs.readdirSync;
|
|
export const readFileSync = fs.readFileSync;
|
|
export const realpathSync = fs.realpathSync;
|
|
|