src/indexOld.js
function addMachine(name) {
        return co(function*(){
            debug("Adding a new machine with the name '%s'", name);
            let manifest = getManifest();

            if(manifest.machines[name]) {
                debug("Machine already exists");
                throw new Error("Machine already exists");
            }

            manifest.machines[name] = {
                route: "machines/" + name,
                "versions": {
                    "version1": {
                        "route": "machines/" + name + "/versions/version1",
                        "instances": {}
                    }
                }
            };

            let machineDirPath = "machines/" + name;
            let machineVersionsDirPath = machineDirPath + "/versions";
            let version1DirPath = machineVersionsDirPath + "/version1";
            let version1InstancesDirPath = version1DirPath + "/instances";
            let modelFile = version1DirPath + '/model.scxml';
            let infoFile = version1DirPath + "/info.json";

            debug("Creating the directories");
            fs.mkdirSync(repositoryPath + "/" + machineDirPath);
            fs.mkdirSync(repositoryPath + "/" + machineVersionsDirPath);
            fs.mkdirSync(repositoryPath + "/" + version1DirPath);
            fs.mkdirSync(repositoryPath + "/" + version1InstancesDirPath);

            debug("Creating the base.scxml file");
            fs.copySync(__dirname + '/base.scxml', repositoryPath + "/" + modelFile);

            debug("Creating the version info.json file");
            let infoVersion1 = { "isSealed": false };
            jsonfile.writeFileSync(repositoryPath + "/" + infoFile, infoVersion1);

            debug("Setting the manifest");
            setManifest(manifest);

            yield _commit(null, ["manifest.json", modelFile, infoFile], "Added '" + name + "' machine");
            debug("A new machine with the name '%s' was successfully added", name);
        });
    }
function addMachine(name) {
        return co(function*(){
            debug("Adding a new machine with the name '%s'", name);
            let manifest = getManifest();

            if(manifest.machines[name]) {
                debug("Machine already exists");
                throw new Error("Machine already exists");
            }

            manifest.machines[name] = {
                route: "machines/" + name,
                "versions": {
                    "version1": {
                        "route": "machines/" + name + "/versions/version1",
                        "instances": {}
                    }
                }
            };

            let machineDirPath = "machines/" + name;
            let machineVersionsDirPath = machineDirPath + "/versions";
            let version1DirPath = machineVersionsDirPath + "/version1";
            let version1InstancesDirPath = version1DirPath + "/instances";
            let modelFile = version1DirPath + '/model.scxml';
            let infoFile = version1DirPath + "/info.json";

            debug("Creating the directories");
            fs.mkdirSync(repositoryPath + "/" + machineDirPath);
            fs.mkdirSync(repositoryPath + "/" + machineVersionsDirPath);
            fs.mkdirSync(repositoryPath + "/" + version1DirPath);
            fs.mkdirSync(repositoryPath + "/" + version1InstancesDirPath);

            debug("Creating the base.scxml file");
            fs.copySync(__dirname + '/base.scxml', repositoryPath + "/" + modelFile);

            debug("Creating the version info.json file");
            let infoVersion1 = { "isSealed": false };
            jsonfile.writeFileSync(repositoryPath + "/" + infoFile, infoVersion1);

            debug("Setting the manifest");
            setManifest(manifest);

            yield _commit(null, ["manifest.json", modelFile, infoFile], "Added '" + name + "' machine");
            debug("A new machine with the name '%s' was successfully added", name);
        });
    }
function addMachine ( name ) { return co ( function * ( ) { debug ( "Adding a new machine with the name '%s'" , name ) ; let manifest = getManifest ( ) ; if ( manifest . machines [ name ] ) { debug ( "Machine already exists" ) ; throw new Error ( "Machine already exists" ) ; } manifest . machines [ name ] = { route : "machines/" + name , "versions" : { "version1" : { "route" : "machines/" + name + "/versions/version1" , "instances" : { } } } } ; let machineDirPath = "machines/" + name ; let machineVersionsDirPath = machineDirPath + "/versions" ; let version1DirPath = machineVersionsDirPath + "/version1" ; let version1InstancesDirPath = version1DirPath + "/instances" ; let modelFile = version1DirPath + '/model.scxml' ; let infoFile = version1DirPath + "/info.json" ; debug ( "Creating the directories" ) ; fs . mkdirSync ( repositoryPath + "/" + machineDirPath ) ; fs . mkdirSync ( repositoryPath + "/" + machineVersionsDirPath ) ; fs . mkdirSync ( repositoryPath + "/" + version1DirPath ) ; fs . mkdirSync ( repositoryPath + "/" + version1InstancesDirPath ) ; debug ( "Creating the base.scxml file" ) ; fs . copySync ( __dirname + '/base.scxml' , repositoryPath + "/" + modelFile ) ; debug ( "Creating the version info.json file" ) ; let infoVersion1 = { "isSealed" : false } ; jsonfile . writeFileSync ( repositoryPath + "/" + infoFile , infoVersion1 ) ; debug ( "Setting the manifest" ) ; setManifest ( manifest ) ; yield _commit ( null , [ "manifest.json" , modelFile , infoFile ] , "Added '" + name + "' machine" ) ; debug ( "A new machine with the name '%s' was successfully added" , name ) ; } ) ; }
Add a new machine to the repository
@method addMachine
@param {String} name The name of the new machine
@returns {Promise}
Add a new machine to the repository