editor/src/project.js
// Simple method handling mkdir and dirname.
Simple method handling mkdir and dirname.
Simple method handling mkdir and dirname .
function mkdir(path, parentDir) {
    var pathList = path.split('/');
    parentDir = parentDir || '';
    if (path.indexOf('/') === 0) {
        pathList.shift();
    }
    pathList = pathList.filter(function (item) {
        return !!item;
    });
    return new Promise(function (resolve, reject) {
        if (!fs) {
            reject(FS_NOT_PREPARED_ERROR);
            return;
        }
        var current = pathList.shift();
        var dirName = parentDir + '/' + current;
        fs.mkdir(dirName, function (err) {
            if (!err || err.code === 'EEXIST') {
                if (pathList.length) {
                    mkdir(pathList.join('/'), dirName).then(resolve).catch(reject);
                }
                else {
                    resolve();
                }
            }
            else {
                reject(err.toString());
            }
        });
    });
}
function mkdir ( path , parentDir ) { var pathList = path . split ( '/' ) ; parentDir = parentDir || '' ; if ( path . indexOf ( '/' ) === 0 ) { pathList . shift ( ) ; } pathList = pathList . filter ( function ( item ) { return ! ! item ; } ) ; return new Promise ( function ( resolve , reject ) { if ( ! fs ) { reject ( FS_NOT_PREPARED_ERROR ) ; return ; } var current = pathList . shift ( ) ; var dirName = parentDir + '/' + current ; fs . mkdir ( dirName , function ( err ) { if ( ! err || err . code === 'EEXIST' ) { if ( pathList . length ) { mkdir ( pathList . join ( '/' ) , dirName ) . then ( resolve ) . catch ( reject ) ; } else { resolve ( ) ; } } else { reject ( err . toString ( ) ) ; } } ) ; } ) ; }
Simple method handling mkdir and dirname.
Simple method handling mkdir and dirname .
// Handle xxx//xxx