本文整理汇总了TypeScript中path.extname函数的典型用法代码示例。如果您正苦于以下问题:TypeScript extname函数的具体用法?TypeScript extname怎么用?TypeScript extname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extname函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getResourceTypeFromUrl
/**
* Get the default resource type for a file based on its extension.
*/
function getResourceTypeFromUrl(url: string): ResourceType|undefined {
return extensionToTypeMapping.get(path.extname(url));
}
开发者ID:MehdiRaash,项目名称:tools,代码行数:6,代码来源:push-manifest.ts
示例2: DataSource
var settingsLocation: SettingsLocation = null;
if (serverSettingsFilePath) {
settingsLocation = {
location: 'local',
readOnly: false, // ToDo: this should be true
uri: serverSettingsFilePath
};
} else {
var initAppSettings = AppSettings.BLANK;
// If a file is specified add it as a dataSource
var fileToLoad = parsedArgs['file'];
if (fileToLoad) {
initAppSettings = initAppSettings.addDataSource(new DataSource({
name: path.basename(fileToLoad, path.extname(fileToLoad)),
engine: 'native',
source: fileToLoad
}));
}
for (var clusterType of CLUSTER_TYPES) {
var host = parsedArgs[clusterType];
if (host) {
initAppSettings = initAppSettings.addCluster(new Cluster({
name: clusterType,
type: clusterType,
host: host,
sourceListScan: 'auto',
sourceListRefreshInterval: 15000,
开发者ID:baeeq,项目名称:pivot,代码行数:29,代码来源:config.ts
示例3: setPath
public setPath(filePath: string)
{
super.path = filePath;
super.name = path.basename(filePath, path.extname(filePath));
}
开发者ID:legatoproject,项目名称:legato-af,代码行数:5,代码来源:annotatedModel.ts
示例4: processFile
matches.forEach(file => {
let resolvedFile = path.resolve(file);
let contents: string = fs.readFileSync(resolvedFile, 'utf8');
let sourceMapFile: string = null;
let resolvedSourceMapFile: string = null;
let sourceMapContent: string = undefined;
let sourceMapMatches = contents.match(/\/\/#\s+sourceMappingURL=(.*)(?:\r?\n|\n|$)/);
if (sourceMapMatches && sourceMapMatches.length === 2) {
let sourceMapUrl = url.parse(sourceMapMatches[1]);
// For now we only support relative pathes
if (sourceMapUrl.protocol || sourceMapUrl.host) {
console.error(`${file}: protocol or host based source map URLs are not supported.`);
hasError = true;
}
let pathname = sourceMapUrl.pathname;
if (path.isAbsolute(pathname)) {
resolvedSourceMapFile = pathname;
} else {
sourceMapFile = pathname;
resolvedSourceMapFile = path.join(path.dirname(file), sourceMapFile);
}
if (fs.existsSync(resolvedSourceMapFile)) {
sourceMapContent = fs.readFileSync(resolvedSourceMapFile, 'utf8');
}
}
let result = processFile(contents, sourceMapContent);
if (result.errors && result.errors.length > 0) {
result.errors.forEach(error => console.error(`${file}${error}`));
hasError = true;
} else {
let outFile = resolvedFile;
let sourceMapOutFile = resolvedSourceMapFile;
if (outDir) {
if (rootDir && resolvedFile.substring(0, rootDir.length) === rootDir) {
outFile = path.join(outDir, resolvedFile.substring(rootDir.length));
} else {
outFile = path.join(outDir, file);
}
if (sourceMapFile) {
sourceMapOutFile = path.join(outDir, sourceMapFile);
}
}
if (result.contents) {
let dirname = path.dirname(outFile);
if (!fs.existsSync(dirname)) {
fs.mkdirSync(path.dirname(outFile));
}
fs.writeFileSync(outFile, result.contents, { encoding: 'utf8' });
}
if (sourceMapOutFile && result.sourceMap) {
fs.writeFileSync(sourceMapOutFile, result.sourceMap, { encoding: 'utf8' });
}
if (result.bundle) {
let extension = path.extname(outFile);
let bundlefile = outFile.substr(0, outFile.length - extension.length) + '.nls.json';
fs.writeFileSync(bundlefile, JSON.stringify(result.bundle, null, 4), { encoding: 'utf8' });
}
}
});
开发者ID:bjacobs3,项目名称:vscode-nls-dev,代码行数:61,代码来源:vscl.ts
示例5: pasteAndShowMessage
let disposable = vscode.commands.registerCommand('copy-file-name.copyFileName', () => {
var fullPath = vscode.window.activeTextEditor.document.fileName;
var extName = path.extname(fullPath);
var fileName = path.basename(fullPath, extName);
pasteAndShowMessage(fileName);
});
开发者ID:nemesv,项目名称:vscode-copy-file-name,代码行数:6,代码来源:extension.ts
示例6: return
let filesInDir: String[] = fs.readdirSync(dir).filter((value: string, index: number, array: string[]) =>
{
return (path.extname(value).match(extRegex) != undefined);
});
开发者ID:Tyriar,项目名称:header-source-switch,代码行数:4,代码来源:extension.ts
示例7: constructor
constructor(path: string) {
this.path = resolve(path);
this.relativePath = relative(REPO_ROOT, this.path);
this.ext = extname(this.path);
}
开发者ID:Jaaess,项目名称:kibana,代码行数:5,代码来源:file.ts
示例8:
return needles.some(function (needle) {
return !_.includes(haystack, path.extname(needle).replace(".", ""));
});
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:3,代码来源:utils.ts
示例9: convertFileToPackage
lines.forEach(line => {
let x = lines;
let y = x;
if (line.startsWith('nose.selector: DEBUG: wantModule <module \'')) {
fileName = line.substring(line.indexOf('\' from \'') + '\' from \''.length);
fileName = fileName.substring(0, fileName.lastIndexOf('\''));
moduleName = line.substring(line.indexOf('nose.selector: DEBUG: wantModule <module \'') + 'nose.selector: DEBUG: wantModule <module \''.length);
moduleName = moduleName.substring(0, moduleName.indexOf('\''));
// We need to display the path relative to the current directory
fileName = fileName.substring(rootDirectory.length + 1);
// we don't care about the compiled file
if (path.extname(fileName) === '.pyc') {
fileName = fileName.substring(0, fileName.length - 1);
}
currentPackage = convertFileToPackage(fileName);
const fullyQualifiedName = path.isAbsolute(fileName) ? fileName : path.resolve(rootDirectory, fileName)
testFile = {
functions: [], suites: [], name: fileName, nameToRun: fileName,
xmlName: currentPackage, time: 0, functionsFailed: 0, functionsPassed: 0,
fullPath: fullyQualifiedName
};
testFiles.push(testFile);
return;
}
if (line.startsWith('nose.selector: DEBUG: wantClass <class \'')) {
let name = extractBetweenDelimiters(line, 'nose.selector: DEBUG: wantClass <class \'', '\'>? True');
const testSuite: TestSuite = {
name: path.extname(name).substring(1), nameToRun: fileName + `:${name}`,
functions: [], suites: [], xmlName: name, time: 0, isUnitTest: false,
isInstance: false, functionsFailed: 0, functionsPassed: 0
};
testFile.suites.push(testSuite);
return;
}
if (line.startsWith('nose.selector: DEBUG: wantClass ')) {
let name = extractBetweenDelimiters(line, 'nose.selector: DEBUG: wantClass ', '? True');
const testSuite: TestSuite = {
name: path.extname(name).substring(1), nameToRun: `${fileName}:.${name}`,
functions: [], suites: [], xmlName: name, time: 0, isUnitTest: false,
isInstance: false, functionsFailed: 0, functionsPassed: 0
};
testFile.suites.push(testSuite);
return;
}
if (line.startsWith('nose.selector: DEBUG: wantMethod <unbound method ')) {
const name = extractBetweenDelimiters(line, 'nose.selector: DEBUG: wantMethod <unbound method ', '>? True');
const fnName = path.extname(name).substring(1);
const clsName = path.basename(name, path.extname(name));
const fn: TestFunction = {
name: fnName, nameToRun: `${fileName}:${clsName}.${fnName}`,
time: 0, functionsFailed: 0, functionsPassed: 0
};
let cls = testFile.suites.find(suite => suite.name === clsName);
if (!cls) {
debugger;
}
cls.functions.push(fn);
return;
}
if (line.startsWith('nose.selector: DEBUG: wantFunction <function ')) {
const name = extractBetweenDelimiters(line, 'nose.selector: DEBUG: wantFunction <function ', ' at ');
const fn: TestFunction = {
name: name, nameToRun: `${fileName}:${name}`,
time: 0, functionsFailed: 0, functionsPassed: 0
};
if (!testFile) {
debugger;
}
testFile.functions.push(fn);
return;
}
});
开发者ID:Tyriar,项目名称:pythonVSCode,代码行数:76,代码来源:collector.ts
示例10: addVideo
async function addVideo (req: express.Request, res: express.Response) {
const videoPhysicalFile = req.files['videofile'][0]
const videoInfo: VideoCreate = req.body
// Prepare data so we don't block the transaction
const videoData = {
name: videoInfo.name,
remote: false,
extname: extname(videoPhysicalFile.filename),
category: videoInfo.category,
licence: videoInfo.licence,
language: videoInfo.language,
commentsEnabled: videoInfo.commentsEnabled || false,
waitTranscoding: videoInfo.waitTranscoding || false,
state: CONFIG.TRANSCODING.ENABLED ? VideoState.TO_TRANSCODE : VideoState.PUBLISHED,
nsfw: videoInfo.nsfw || false,
description: videoInfo.description,
support: videoInfo.support,
privacy: videoInfo.privacy,
duration: videoPhysicalFile['duration'], // duration was added by a previous middleware
channelId: res.locals.videoChannel.id
}
const video = new VideoModel(videoData)
video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
// Build the file object
const { videoFileResolution } = await getVideoFileResolution(videoPhysicalFile.path)
const videoFileData = {
extname: extname(videoPhysicalFile.filename),
resolution: videoFileResolution,
size: videoPhysicalFile.size
}
const videoFile = new VideoFileModel(videoFileData)
// Move physical file
const videoDir = CONFIG.STORAGE.VIDEOS_DIR
const destination = join(videoDir, video.getVideoFilename(videoFile))
await renamePromise(videoPhysicalFile.path, destination)
// This is important in case if there is another attempt in the retry process
videoPhysicalFile.filename = video.getVideoFilename(videoFile)
videoPhysicalFile.path = destination
// Process thumbnail or create it from the video
const thumbnailField = req.files['thumbnailfile']
if (thumbnailField) {
const thumbnailPhysicalFile = thumbnailField[0]
await processImage(thumbnailPhysicalFile, join(CONFIG.STORAGE.THUMBNAILS_DIR, video.getThumbnailName()), THUMBNAILS_SIZE)
} else {
await video.createThumbnail(videoFile)
}
// Process preview or create it from the video
const previewField = req.files['previewfile']
if (previewField) {
const previewPhysicalFile = previewField[0]
await processImage(previewPhysicalFile, join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName()), PREVIEWS_SIZE)
} else {
await video.createPreview(videoFile)
}
// Create the torrent file
await video.createTorrentAndSetInfoHash(videoFile)
const videoCreated = await sequelizeTypescript.transaction(async t => {
const sequelizeOptions = { transaction: t }
const videoCreated = await video.save(sequelizeOptions)
// Do not forget to add video channel information to the created video
videoCreated.VideoChannel = res.locals.videoChannel
videoFile.videoId = video.id
await videoFile.save(sequelizeOptions)
video.VideoFiles = [ videoFile ]
// Create tags
if (videoInfo.tags !== undefined) {
const tagInstances = await TagModel.findOrCreateTags(videoInfo.tags, t)
await video.$set('Tags', tagInstances, sequelizeOptions)
video.Tags = tagInstances
}
// Schedule an update in the future?
if (videoInfo.scheduleUpdate) {
await ScheduleVideoUpdateModel.create({
videoId: video.id,
updateAt: videoInfo.scheduleUpdate.updateAt,
privacy: videoInfo.scheduleUpdate.privacy || null
}, { transaction: t })
}
await federateVideoIfNeeded(video, true, t)
logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
return videoCreated
})
if (video.state === VideoState.TO_TRANSCODE) {
//.........这里部分代码省略.........
开发者ID:jiang263,项目名称:PeerTube,代码行数:101,代码来源:index.ts
注:本文中的path.extname函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论