index.js
//Creates a Clockwork package using the given manifest
Creates a Clockwork package using the given manifest
Creates a Clockwork package using the given manifest
function generatePackage(manifest) {
        var workingPath = path.resolve(rootPath);
        try {
            fs.mkdirSync(workingPath + '/ClockworkPackageTemp');
        } catch (e) { }
        copyFileSync(workingPath + '/manifest.json', workingPath + '/ClockworkPackageTemp/manifest.json');
        return new Promise(function (res, rej) {
            console.log("Copying project files...");
            ncp(workingPath + '/' + manifest.scope, workingPath + '/ClockworkPackageTemp/' + manifest.scope, function (err) {
                if (err) {
                    console.error(err);
                    rej();
                } else {
                    res()
                }
            })
        }).then(function () {
            return preprocessPackage(workingPath + "/ClockworkPackageTemp");
        }).then(function (x) {
            return new Promise(function (res, rej) {
                try {
                    fs.unlinkSync(workingPath + "/" + manifest.name + '.cw');
                } catch (e) { }
                var output = fs.createWriteStream(workingPath + "/" + manifest.name + '.cw');
                var archive = archiver('zip');
                output.on('close', function () {
                    console.log("Deleting temporary files...");
                    deleteFolderRecursive(workingPath + "/ClockworkPackageTemp/");
                    res();
                });
                archive.on('error', function (err) {
                    throw err;
                });
                archive.pipe(output);
                console.log("Creating package..");
                archive.glob("**", {
                    cwd: workingPath + "/ClockworkPackageTemp/"
                })
                archive.finalize();
            });
        }).then(function (x) { return workingPath + "/" + manifest.name + ".cw" });
    }
function generatePackage ( manifest ) { var workingPath = path . resolve ( rootPath ) ; try { fs . mkdirSync ( workingPath + '/ClockworkPackageTemp' ) ; } catch ( e ) { } copyFileSync ( workingPath + '/manifest.json' , workingPath + '/ClockworkPackageTemp/manifest.json' ) ; return new Promise ( function ( res , rej ) { console . log ( "Copying project files..." ) ; ncp ( workingPath + '/' + manifest . scope , workingPath + '/ClockworkPackageTemp/' + manifest . scope , function ( err ) { if ( err ) { console . error ( err ) ; rej ( ) ; } else { res ( ) } } ) } ) . then ( function ( ) { return preprocessPackage ( workingPath + "/ClockworkPackageTemp" ) ; } ) . then ( function ( x ) { return new Promise ( function ( res , rej ) { try { fs . unlinkSync ( workingPath + "/" + manifest . name + '.cw' ) ; } catch ( e ) { } var output = fs . createWriteStream ( workingPath + "/" + manifest . name + '.cw' ) ; var archive = archiver ( 'zip' ) ; output . on ( 'close' , function ( ) { console . log ( "Deleting temporary files..." ) ; deleteFolderRecursive ( workingPath + "/ClockworkPackageTemp/" ) ; res ( ) ; } ) ; archive . on ( 'error' , function ( err ) { throw err ; } ) ; archive . pipe ( output ) ; console . log ( "Creating package.." ) ; archive . glob ( "**" , { cwd : workingPath + "/ClockworkPackageTemp/" } ) archive . finalize ( ) ; } ) ; } ) . then ( function ( x ) { return workingPath + "/" + manifest . name + ".cw" } ) ; }
Creates a Clockwork package using the given manifest
Creates a Clockwork package using the given manifest
// archive.bulk([ //     { expand: true, cwd: workingPath + "/ClockworkPackageTemp/", src: ['**'], dest: '' } // ]);