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.
28 lines
471 B
28 lines
471 B
import * as fs from 'fs';
|
|
import { dirname } from './path.js';
|
|
|
|
export * from 'fs';
|
|
|
|
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();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|