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() }) })
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) }
function readSync (cache, integrity, opts) { opts = ReadOpts(opts) return withContentSriSync(cache, integrity, (cpath, sri) => { const data = fs.readFileSync(cpath) if (typeof opts.size === 'number' && opts.size !== data.length) { throw sizeError(opts.size, data.length) } else if (ssri.checkData(data, sri)) { return data } else { throw integrityError(sri, cpath) } }) }
var return_source = function(pid) { var problemManager = require('./ProblemManager'); problemManager.sourceList(pid, function(source_list) { if (source_list.length === 0) source_list.push("source"); var source = []; for (var i = 0; i < source_list.length; i++) { var spath = config.JUDGE.path + "submission/" + sid + "-" + i; try { var data = fs.readFileSync(spath, 'utf8'); source.push({title: source_list[i], code: data.toString()}); } catch (err) { } } callback(source); }); }
test('\'npm install-test\' should repair package-lock.json', function (t) { common.npm(['install-test'], EXEC_OPTS, function (err, code, stderr, stdout) { if (err) throw err t.comment(stdout.trim()) t.comment(stderr.trim()) t.is(code, 0, 'npm install did not raise error code') var lockfile = JSON.parse(fs.readFileSync(path.join(pkg, 'package-lock.json'))) t.same( lockfile, expected, 'package-lock.json should be repaired' ) t.end() }) })
// Take a template path, read/load it's content and return it. If we fail to load the file, we will throw an appropriate // error. // Note: The template file should be encoded in UCS2/UTF16LE (that's the encoding that Enigma Virtual Box expects) function loadTemplate(templatePath) { var contents; try { contents = fs.readFileSync(resolvePath(templatePath), 'ucs2'); // We remove indents to trim down template size (you can always beautify/prettify the end result if you wish) contents = contents.replace(RE.PRE_TAG_INDENTS, '<'); } catch (e) { e.message = "Failed to load template. Template path: '" + templatePath + "'.\n" + e.message; throw e; } return contents; }
const check = opts => t => common.npm( [ '--loglevel', 'silent', '--registry', common.registry, '--save', 'install', 'underscore@1.3.1' ], EXEC_OPTS ).then(([code, err, out]) => { t.notOk(code, 'npm install exited without raising an error code') const pkgPath = path.resolve(pkg, 'package.json') const pkgStr = fs.readFileSync(pkgPath, 'utf8') t.match(pkgStr, opts.match) t.notMatch(pkgStr, opts.notMatch) const pkgLockPath = path.resolve(pkg, 'package-lock.json') const pkgLockStr = fs.readFileSync(pkgLockPath, 'utf8') t.match(pkgLockStr, opts.match) t.notMatch(pkgLockStr, opts.notMatch) t.end() })
while (tryCount < maxTry) { try { var x = fs.readFileSync(tmpdir + '/status') if (x.toString() === '0') { break child[file] = fs.readFileSync(tmpdir + '/' + file, options.encoding) setTimeout(unlinkFile, 500, tmpdir + '/' + file) })
function bucketEntriesSync (bucket, filter) { const data = fs.readFileSync(bucket, 'utf8') return _bucketEntries(data, filter) }
var configPath = path.join(addonPath, 'build', 'config.gypi') try { data = fs.readFileSync(configPath, 'utf8') } catch (err) { t.error(err)
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() }) })