support/distribution/package.js
function findFilesToPackage(dir, callback) {
    var cwd = process.cwd();
    process.chdir(dir);

    var gitls = spawn('git', ['ls-files']),
        // This gets the full path to each file in each submodule
        subls = spawn('git', ['submodule', 'foreach', 'for file in `git ls-files`; do echo "$path/$file"; done']);
        // List all node_modules
        modls = spawn('find', ['node_modules']);


    var mainFileList = '';
    gitls.stdout.on('data', function (data) {
        mainFileList += data;
    });
    gitls.on('exit', returnFileList);

    var subFileList = '';
    subls.stdout.on('data', function (data) {
        subFileList += data;
    });
    subls.on('exit', returnFileList);
    
    var modFileList = '';
    modls.stdout.on('data', function (data) {
        modFileList += data;
    });
    modls.on('exit', returnFileList);

    var lsCount = 0;
    function returnFileList(code) {
        lsCount++;
        if (lsCount < 3) {
            return;
        }
        process.chdir(cwd);

        // Convert \n separated list of filenames into a sorted array
        var fileList = (mainFileList.trim() + '\n' + subFileList.trim() + '\n' + modFileList.trim()).split('\n').filter(function(file) {
            // Ignore entering submodule messages
            if (file.indexOf('Entering ') === 0) {
                return;
            }

            // Ignore hidden and backup files
            if (file.split('/').pop()[0] == '.' || file[file.length - 1] == '~') {
                return;
            }

            // Submodules appear in ls-files but aren't files. Skip them
            if (fs.statSync(path.join(dir, file)).isDirectory()) {
                return;
            }

            
            return file;
        }).sort();

        callback(fileList);
    }

}
function findFilesToPackage(dir, callback) {
    var cwd = process.cwd();
    process.chdir(dir);

    var gitls = spawn('git', ['ls-files']),
        // This gets the full path to each file in each submodule
        subls = spawn('git', ['submodule', 'foreach', 'for file in `git ls-files`; do echo "$path/$file"; done']);
        // List all node_modules
        modls = spawn('find', ['node_modules']);


    var mainFileList = '';
    gitls.stdout.on('data', function (data) {
        mainFileList += data;
    });
    gitls.on('exit', returnFileList);

    var subFileList = '';
    subls.stdout.on('data', function (data) {
        subFileList += data;
    });
    subls.on('exit', returnFileList);
    
    var modFileList = '';
    modls.stdout.on('data', function (data) {
        modFileList += data;
    });
    modls.on('exit', returnFileList);

    var lsCount = 0;
    function returnFileList(code) {
        lsCount++;
        if (lsCount < 3) {
            return;
        }
        process.chdir(cwd);

        // Convert \n separated list of filenames into a sorted array
        var fileList = (mainFileList.trim() + '\n' + subFileList.trim() + '\n' + modFileList.trim()).split('\n').filter(function(file) {
            // Ignore entering submodule messages
            if (file.indexOf('Entering ') === 0) {
                return;
            }

            // Ignore hidden and backup files
            if (file.split('/').pop()[0] == '.' || file[file.length - 1] == '~') {
                return;
            }

            // Submodules appear in ls-files but aren't files. Skip them
            if (fs.statSync(path.join(dir, file)).isDirectory()) {
                return;
            }

            
            return file;
        }).sort();

        callback(fileList);
    }

}
function findFilesToPackage ( dir , callback ) { var cwd = process . cwd ( ) ; process . chdir ( dir ) ; var gitls = spawn ( 'git' , [ 'ls-files' ] ) , // This gets the full path to each file in each submodule subls = spawn ( 'git' , [ 'submodule' , 'foreach' , 'for file in `git ls-files`; do echo "$path/$file"; done' ] ) ; // List all node_modules modls = spawn ( 'find' , [ 'node_modules' ] ) ; var mainFileList = '' ; gitls . stdout . on ( 'data' , function ( data ) { mainFileList += data ; } ) ; gitls . on ( 'exit' , returnFileList ) ; var subFileList = '' ; subls . stdout . on ( 'data' , function ( data ) { subFileList += data ; } ) ; subls . on ( 'exit' , returnFileList ) ; var modFileList = '' ; modls . stdout . on ( 'data' , function ( data ) { modFileList += data ; } ) ; modls . on ( 'exit' , returnFileList ) ; var lsCount = 0 ; function returnFileList ( code ) { lsCount ++ ; if ( lsCount < 3 ) { return ; } process . chdir ( cwd ) ; // Convert \n separated list of filenames into a sorted array var fileList = ( mainFileList . trim ( ) + '\n' + subFileList . trim ( ) + '\n' + modFileList . trim ( ) ) . split ( '\n' ) . filter ( function ( file ) { // Ignore entering submodule messages if ( file . indexOf ( 'Entering ' ) === 0 ) { return ; } // Ignore hidden and backup files if ( file . split ( '/' ) . pop ( ) [ 0 ] == '.' || file [ file . length - 1 ] == '~' ) { return ; } // Submodules appear in ls-files but aren't files. Skip them if ( fs . statSync ( path . join ( dir , file ) ) . isDirectory ( ) ) { return ; } return file ; } ) . sort ( ) ; callback ( fileList ) ; } }
Uses git to find the files we want to install. If a file isn't commited,
then it won't be installed.

@param {String} dir The directory that will be installed
@returns String[] Array of file paths
Uses git to find the files we want to install . If a file isn t commited then it won t be installed .