本文整理汇总了TypeScript中vs/base/common/amd.getPathFromAmdModule函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getPathFromAmdModule函数的具体用法?TypeScript getPathFromAmdModule怎么用?TypeScript getPathFromAmdModule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getPathFromAmdModule函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Files: extraFiles only', function (done: () => void) {
this.timeout(testTimeout);
const engine = new FileSearchEngine({
type: QueryType.File,
folderQueries: [],
extraFileResources: [
URI.file(path.normalize(path.join(getPathFromAmdModule(require, './fixtures'), 'site.css'))),
URI.file(path.normalize(path.join(getPathFromAmdModule(require, './fixtures'), 'examples', 'company.js'))),
URI.file(path.normalize(path.join(getPathFromAmdModule(require, './fixtures'), 'index.html')))
],
filePattern: '*.js'
});
let count = 0;
let res: IRawFileMatch;
engine.search((result) => {
if (result) {
count++;
}
res = result;
}, () => { }, (error) => {
assert.ok(!error);
assert.equal(count, 1);
assert.equal(path.basename(res.relativePath), 'company.js');
done();
});
});
示例2: test
test('Files: extraFiles only (with include)', function (done: () => void) {
this.timeout(testTimeout);
let engine = new FileSearchEngine({
folderQueries: [],
extraFiles: [
path.normalize(path.join(getPathFromAmdModule(require, './fixtures'), 'site.css')),
path.normalize(path.join(getPathFromAmdModule(require, './fixtures'), 'examples', 'company.js')),
path.normalize(path.join(getPathFromAmdModule(require, './fixtures'), 'index.html'))
],
filePattern: '*.*',
includePattern: { '**/*.css': true }
});
let count = 0;
let res: IRawFileMatch;
engine.search((result) => {
if (result) {
count++;
}
res = result;
}, () => { }, (error) => {
assert.ok(!error);
assert.equal(count, 1);
assert.equal(path.basename(res.relativePath), 'site.css');
done();
});
});
示例3: exec
exec('which ps', {}, (err, stdout, stderr) => {
if (err || stderr) {
if (process.platform !== 'linux') {
reject(err || new Error(stderr.toString()));
} else {
const cmd = JSON.stringify(getPathFromAmdModule(require, 'vs/base/node/ps.sh'));
exec(cmd, {}, (err, stdout, stderr) => {
if (err || stderr) {
reject(err || new Error(stderr.toString()));
} else {
parsePsOutput(stdout, addToTree);
calculateLinuxCpuUsage();
}
});
}
} else {
const ps = stdout.toString().trim();
const args = '-ax -o pid=,ppid=,pcpu=,pmem=,command=';
// Set numeric locale to ensure '.' is used as the decimal separator
exec(`${ps} ${args}`, { maxBuffer: 1000 * 1024, env: { LC_NUMERIC: 'en_US.UTF-8' } }, (err, stdout, stderr) => {
if (err || stderr) {
reject(err || new Error(stderr.toString()));
} else {
parsePsOutput(stdout, addToTree);
if (process.platform === 'linux') {
calculateLinuxCpuUsage();
} else {
resolve(rootItem);
}
}
});
}
});
示例4: calculateLinuxCpuUsage
} else { // OS X & Linux
function calculateLinuxCpuUsage() {
// Flatten rootItem to get a list of all VSCode processes
let processes = [rootItem];
const pids: number[] = [];
while (processes.length) {
const process = processes.shift();
if (process) {
pids.push(process.pid);
if (process.children) {
processes = processes.concat(process.children);
}
}
}
// The cpu usage value reported on Linux is the average over the process lifetime,
// recalculate the usage over a one second interval
// JSON.stringify is needed to escape spaces, https://github.com/nodejs/node/issues/6803
let cmd = JSON.stringify(getPathFromAmdModule(require, 'vs/base/node/cpuUsage.sh'));
cmd += ' ' + pids.join(' ');
exec(cmd, {}, (err, stdout, stderr) => {
if (err || stderr) {
reject(err || new Error(stderr.toString()));
} else {
const cpuUsage = stdout.toString().split('\n');
for (let i = 0; i < pids.length; i++) {
const processInfo = map.get(pids[i])!;
processInfo.load = parseFloat(cpuUsage[i]);
}
resolve(rootItem);
}
});
}
示例5: test
test('readToMatchingString - empty', function () {
const file = getPathFromAmdModule(require, './fixtures/empty.txt');
return stream.readToMatchingString(file, '\n', 10, 100).then((result: string) => {
assert.equal(result, null);
});
});
示例6: test
test('detectEncodingFromBuffer (QWOFF saved as TXT)', function () {
const file = getPathFromAmdModule(require, './fixtures/some.qwoff.txt');
return readExactlyByFile(file, 512).then(buffer => {
const mimes = encoding.detectEncodingFromBuffer(buffer);
assert.equal(mimes.seemsBinary, true);
});
});