path#ParsedPath TypeScript Examples
The following examples show how to use
path#ParsedPath.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: fileUtils.ts From elasticsearch-index-migrate with MIT License | 6 votes |
export function loadMigrationScriptFilePaths(
indexName: string,
migrationFilePaths: string[],
isNaturalIndexName: boolean,
indexVersion?: string
): path.ParsedPath[] {
return migrationFilePaths
.filter((value) => {
const parentPath = makeParentPath(indexName, isNaturalIndexName, indexVersion);
const migrationFilePath = path.parse(value);
return (
migrationFilePath.dir.includes(parentPath) &&
migrationFilePath.dir.lastIndexOf(parentPath) + parentPath.length ===
migrationFilePath.dir.length
);
})
.map(path.parse)
.filter((value) => value.ext === '.json');
}
Example #2
Source File: fileUtils.ts From elasticsearch-index-migrate with MIT License | 6 votes |
export function loadMigrationScripts(migrationFileParsedPath: ParsedPath[]): ResolvedMigration[] {
return migrationFileParsedPath.map((value) => {
const resolvedMigration = JSON.parse(
fs.readFileSync(path.join(value.dir, value.base), 'utf8')
) as ResolvedMigration;
resolvedMigration.physicalLocation = value;
const match = value.name.match(fileNameRegexp) as RegExpMatchArray;
if (match !== null && match.length > 1) {
resolvedMigration.version = match[1];
}
return resolvedMigration;
});
}
Example #3
Source File: FileSystemStoredFile.ts From nestjs-form-data with MIT License | 5 votes |
private static makeFileNameWithSalt(originalName: string): string {
const parsed: ParsedPath = path.parse(originalName);
return `${parsed.name}-${uid(6)}${parsed.ext}`;
}