return when.promise(function (resolve, reject) { var gunzip$; var read$ = fs.createReadStream(source); var write$ = fs.createWriteStream(target);
function lastRun (cache) { return fs.readFileAsync( path.join(cache, '_lastverified'), 'utf8' ).then(data => new Date(+data)) }
var return_result = function(sid) { var spath = config.JUDGE.path + "submission/" + sid + "-z"; fs.readFile(spath, 'utf8', function(err, buf_data){ if (err) { return callback(message.source_result_error); } return callback(result_json(buf_data.toString())); }); }
test('creates a unique tmpdir inside the cache', t => { return tmp.mkdir(CACHE).then(dir => { t.match(path.relative(CACHE, dir), /^tmp[\\/].*/, 'returns a path inside tmp') return fs.statAsync(dir) }).then(stat => { t.ok(stat.isDirectory(), 'path points to an existing directory') }) })
function mockCache () { const fixture = new Tacks(CacheContent({ [INTEGRITY]: CONTENT })) fixture.create(CACHE) return fs.mkdirAsync(path.join(CACHE, 'tmp')).then(() => { return index.insert(CACHE, KEY, INTEGRITY, { metadata: METADATA }) }) }
function fileExists (file) { try { return !!fs.statSync(path.resolve(targetpath, 'package', file)) } catch (_) { return false } }
fs.readFile(prob_path, 'utf8', function(err, buf_data) { if (err) return callback('err'); return callback(buf_data.toString()); });
function readCAFile (filename) { // The CA file can contain multiple certificates so split on certificate // boundaries. [\S\s]*? is used to match everything including newlines. var ca = fs.readFileSync(filename, 'utf8') var re = /(-----BEGIN CERTIFICATE-----[\S\s]*?-----END CERTIFICATE-----)/g return ca.match(re) }
fs.writeFile(md_path, md_text, function(err) { if(err) console.log(err); console.log("The file was saved!"); });
test('\'npm install ../package@1.2.3\' should install local pkg from sub path', function (t) { common.npm(['install', '--loglevel=silent', target], EXEC_OPTS, function (err, code) { if (err) throw err var p = path.resolve(pkg, 'node_modules/install-at-sub-path-locally-mock/package.json') t.equal(code, 0, 'npm install exited with code') t.ok(JSON.parse(fs.readFileSync(p, 'utf8'))) t.end() }) })
var testdataList = function(pid, callback) { var source_list_path = config.JUDGE.testdata.path + "/" + pid + "/subtasks.py"; fs.readFile(source_list_path, 'utf8', function(err, buf_data) { var testdata_list = []; if (!err) testdata_list = eval('(' + buf_data.toString() + ')'); callback(testdata_list); }); }
test('setup', function (t) { var root = path.resolve(pkg, target) mkdirp.sync(root) fs.writeFileSync( path.join(root, 'package.json'), JSON.stringify(json, null, 2) ) mkdirp.sync(path.resolve(pkg, 'node_modules')) t.end() })
t.test('\'npm ci\' should work', function (t) { common.npm(['ci', '--loglevel=silent'], EXEC_OPTS, function (err, code) { if (err) throw err t.equal(code, 0, 'npm install exited with code') t.ok(fs.statSync(path.resolve(pkg, 'node_modules/local-dependency/package.json')).isFile(), 'local dependency package.json exists') t.ok(fs.statSync(path.resolve(pkg, 'node_modules/local-dependency/node_modules/test-package')).isDirectory(), 'transitive dependency installed') t.end() }) })
test('installing local package with local dependency', function (t) { common.npm( ['install'], {cwd: cwd}, function (er, code, stdout, stderr) { t.is(code, 0, 'no error code') t.is(stderr, '', 'no error output') t.ok(fs.existsSync(path.join(cwd, 'node_modules', '2')), 'installed direct dep') t.ok(fs.existsSync(path.join(cwd, 'node_modules', '1')), 'installed indirect dep') t.end() } ) })
test('\'running npm install ../package@1.2.3\' should not break on sub path re-install', function (t) { common.npm(['install', '--loglevel=silent', target], EXEC_OPTS, function (err, code) { if (err) throw err var p = path.resolve(pkg, 'node_modules/install-at-sub-path-locally-mock/package.json') t.equal(code, 0, 'npm install exited with code') t.ok(JSON.parse(fs.readFileSync(p, 'utf8'))) t.end() }) })