support/distribution/package.js
function generateNSISScript(files, callback) {
    sys.puts('Generating NSIS script');
    var installFileList = '  SetOverwrite try\n',
        removeFileList  = '',
        removeDirList   = '';

    files = files.filter(function(file) {
        // Ignore node-builds for other platforms
        if (~file.indexOf('node-builds') && !~file.indexOf('cyg') && !~file.indexOf('tmp') && !~file.indexOf('etc')) {
            return;
        }

        return file;
    });


    // Generate the install and remove lists
    var prevDirname, i, len;
    for (i = 0, len = files.length; i < len; i++) {
        var file = files[i];
        var dirname = path.dirname(file);

        if (dirname != prevDirname) {
            prevDirname = dirname;
            installFileList += '  SetOutPath "$INSTDIR\\' + dirname.replace(/\//g, '\\') + '"\n';
            removeDirList  += '  RMDir "$INSTDIR\\' + dirname.replace(/\//g, '\\') + '"\n';
        }

        var m;
        if ((m = file.match(/\/?(README|LICENSE)(.md)?$/))) {
            // Rename README and LICENSE so they end in .txt
            installFileList += '  File /oname=' + m[1] + '.txt "${ROOT_PATH}\\' + file.replace(/\//g, '\\') + '"\n';
        } else {
            installFileList += '  File "${ROOT_PATH}\\' + file.replace(/\//g, '\\') + '"\n';
        }
        removeFileList  += '  Delete "$INSTDIR\\' + file.replace(/\//g, '\\') + '"\n';
    }


    var tmp = new Template(fs.readFileSync(path.join(__dirname, 'installer_nsi.template'), 'utf8'));
    var data = tmp.substitute({
        root_path: path.join(__dirname, '../..'),
        output_path: OUTPUT_PATH,
        version: 'v' + VERSION,
        install_file_list: installFileList,
        remove_file_list: removeFileList,
        remove_dir_list: removeDirList
    });

    callback(data);
}
function generateNSISScript(files, callback) {
    sys.puts('Generating NSIS script');
    var installFileList = '  SetOverwrite try\n',
        removeFileList  = '',
        removeDirList   = '';

    files = files.filter(function(file) {
        // Ignore node-builds for other platforms
        if (~file.indexOf('node-builds') && !~file.indexOf('cyg') && !~file.indexOf('tmp') && !~file.indexOf('etc')) {
            return;
        }

        return file;
    });


    // Generate the install and remove lists
    var prevDirname, i, len;
    for (i = 0, len = files.length; i < len; i++) {
        var file = files[i];
        var dirname = path.dirname(file);

        if (dirname != prevDirname) {
            prevDirname = dirname;
            installFileList += '  SetOutPath "$INSTDIR\\' + dirname.replace(/\//g, '\\') + '"\n';
            removeDirList  += '  RMDir "$INSTDIR\\' + dirname.replace(/\//g, '\\') + '"\n';
        }

        var m;
        if ((m = file.match(/\/?(README|LICENSE)(.md)?$/))) {
            // Rename README and LICENSE so they end in .txt
            installFileList += '  File /oname=' + m[1] + '.txt "${ROOT_PATH}\\' + file.replace(/\//g, '\\') + '"\n';
        } else {
            installFileList += '  File "${ROOT_PATH}\\' + file.replace(/\//g, '\\') + '"\n';
        }
        removeFileList  += '  Delete "$INSTDIR\\' + file.replace(/\//g, '\\') + '"\n';
    }


    var tmp = new Template(fs.readFileSync(path.join(__dirname, 'installer_nsi.template'), 'utf8'));
    var data = tmp.substitute({
        root_path: path.join(__dirname, '../..'),
        output_path: OUTPUT_PATH,
        version: 'v' + VERSION,
        install_file_list: installFileList,
        remove_file_list: removeFileList,
        remove_dir_list: removeDirList
    });

    callback(data);
}
function generateNSISScript ( files , callback ) { sys . puts ( 'Generating NSIS script' ) ; var installFileList = '  SetOverwrite try\n' , removeFileList = '' , removeDirList = '' ; files = files . filter ( function ( file ) { // Ignore node-builds for other platforms if ( ~ file . indexOf ( 'node-builds' ) && ! ~ file . indexOf ( 'cyg' ) && ! ~ file . indexOf ( 'tmp' ) && ! ~ file . indexOf ( 'etc' ) ) { return ; } return file ; } ) ; // Generate the install and remove lists var prevDirname , i , len ; for ( i = 0 , len = files . length ; i < len ; i ++ ) { var file = files [ i ] ; var dirname = path . dirname ( file ) ; if ( dirname != prevDirname ) { prevDirname = dirname ; installFileList += '  SetOutPath "$INSTDIR\\' + dirname . replace ( / \/ / g , '\\' ) + '"\n' ; removeDirList += '  RMDir "$INSTDIR\\' + dirname . replace ( / \/ / g , '\\' ) + '"\n' ; } var m ; if ( ( m = file . match ( / \/?(README|LICENSE)(.md)?$ / ) ) ) { // Rename README and LICENSE so they end in .txt installFileList += '  File /oname=' + m [ 1 ] + '.txt "${ROOT_PATH}\\' + file . replace ( / \/ / g , '\\' ) + '"\n' ; } else { installFileList += '  File "${ROOT_PATH}\\' + file . replace ( / \/ / g , '\\' ) + '"\n' ; } removeFileList += '  Delete "$INSTDIR\\' + file . replace ( / \/ / g , '\\' ) + '"\n' ; } var tmp = new Template ( fs . readFileSync ( path . join ( __dirname , 'installer_nsi.template' ) , 'utf8' ) ) ; var data = tmp . substitute ( { root_path : path . join ( __dirname , '../..' ) , output_path : OUTPUT_PATH , version : 'v' + VERSION , install_file_list : installFileList , remove_file_list : removeFileList , remove_dir_list : removeDirList } ) ; callback ( data ) ; }
Generates an NSIS installer script to install the contents of a given
directory and returns it as a string.

@param {String} dir The directory that will be installed
@returns String The contents of the NSIS script
Generates an NSIS installer script to install the contents of a given directory and returns it as a string .