本文整理匯總了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);
});
});