You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
816 B
JavaScript

'use strict';
const Promise = require("bluebird");
const fs = Promise.promisifyAll(require("fs"));
const path = require("path");
const util = require("util");
const parse = require("./lib");
let completed = 0;
Promise.try(() => {
return fs.readdirAsync("/nix/store")
}).filter((storePath) => {
return /.+\.drv$/.test(storePath);
}).map((storePath, i, total) => {
return Promise.try(() => {
return fs.readFileAsync(path.join("/nix/store", storePath));
}).then((contents) => {
parse(contents.toString());
}).catch((err) => {
console.error(path.join("/nix/store", storePath));
console.error(util.inspect(err, {colors: true}));
throw err;
}).then(() => {
completed += 1;
console.log(`Completed ${completed}/${total} derivations...`);
});
}, {concurrency: 1}).catch((err) => {
// do nothing
});