本文整理汇总了TypeScript中path.posix.join方法的典型用法代码示例。如果您正苦于以下问题:TypeScript posix.join方法的具体用法?TypeScript posix.join怎么用?TypeScript posix.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path.posix
的用法示例。
在下文中一共展示了posix.join方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getUploadPriority
const uploadObserver = new Observable<string>(observer => {
for (const file of localFiles) {
const localPath = path.resolve(path.join('dist', file))
const remotePath = path.posix.join(DEPLOY_DIR, file)
const payload: UploadPayload = {
localPath,
observer,
remotePath,
title: file,
}
uploadQueue.push(payload, getUploadPriority(file))
}
})
示例2: visitSpec
export function createLocalProxy<T>(serviceSchema: s.Class, service:T, client: Client, server: Server) {
visitSpec({
onPromise(memberSchema:s.ClassMember, functionT:s.FunctionType):void {
let name = memberSchema.name
let methodPath = path.posix.join(memberSchema.parent.container.name, memberSchema.parent.name, memberSchema.name).replace(/\//g, '-')
server._post('/' + methodPath, function(args:any[]){
return service[name].apply(service, args)
})
},
onObservable(memberSchema:s.ClassMember) {
// TODO
}
}, serviceSchema)
}
示例3:
sourcePath.some((sourcePath) =>
{
let newPath = path.posix.join(sourcePath, thePath);
let absolutePath = newPath;
if(!path.isAbsolute(absolutePath))
{
absolutePath = path.resolve(folderPath, absolutePath);
}
if(fs.existsSync(absolutePath))
{
thePath = newPath;
return true;
}
return false;
});
示例4: origBazelHostShouldNameModule
bazelHost.shouldNameModule = (fileName: string) => {
const flatModuleOutPath =
path.posix.join(bazelOpts.package, compilerOpts.flatModuleOutFile + '.ts');
// The bundle index file is synthesized in bundle_index_host so it's not in the
// compilationTargetSrc.
// However we still want to give it an AMD module name for devmode.
// We can't easily tell which file is the synthetic one, so we build up the path we expect
// it to have and compare against that.
if (fileName === path.posix.join(compilerOpts.baseUrl, flatModuleOutPath)) return true;
// Also handle the case the target is in an external repository.
// Pull the workspace name from the target which is formatted as `@wksp//package:target`
// if it the target is from an external workspace. If the target is from the local
// workspace then it will be formatted as `//package:target`.
const targetWorkspace = bazelOpts.target.split('/')[0].replace(/^@/, '');
if (targetWorkspace &&
fileName ===
path.posix.join(compilerOpts.baseUrl, 'external', targetWorkspace, flatModuleOutPath))
return true;
return origBazelHostShouldNameModule(fileName) || NGC_GEN_FILES.test(fileName);
};
示例5: catch
/**
* Reads the app configuration from the given YAML file in the `.github`
* directory of the repository.
*
* @example <caption>Contents of <code>.github/config.yml</code>.</caption>
*
* close: true
* comment: Check the specs on the rotary girder.
*
* @example <caption>App that reads from <code>.github/config.yml</code>.</caption>
*
* // Load config from .github/config.yml in the repository
* const config = await context.config('config.yml')
*
* if (config.close) {
* context.github.issues.comment(context.issue({body: config.comment}))
* context.github.issues.edit(context.issue({state: 'closed'}))
* }
*
* @example <caption>Using a <code>defaultConfig</code> object.</caption>
*
* // Load config from .github/config.yml in the repository and combine with default config
* const config = await context.config('config.yml', {comment: 'Make sure to check all the specs.'})
*
* if (config.close) {
* context.github.issues.comment(context.issue({body: config.comment}));
* context.github.issues.edit(context.issue({state: 'closed'}))
* }
*
* @param {string} fileName - Name of the YAML file in the `.github` directory
* @param {object} [defaultConfig] - An object of default config options
* @return {Promise<Object>} - Configuration object read from the file
*/
public async config<T> (fileName: string, defaultConfig?: T) {
const params = this.repo({path: path.posix.join('.github', fileName)})
try {
const res = await this.github.repos.getContent(params)
const config = yaml.safeLoad(Buffer.from(res.data.content, 'base64').toString()) || {}
return Object.assign({}, defaultConfig, config)
} catch (err) {
if (err.code === 404) {
if (defaultConfig) {
return defaultConfig
}
return null
} else {
throw err
}
}
}
示例6: collectFilesInPath
function collectFilesInPath(path: string, relative: string, output: TestFile[]) {
path = resolve(__dirname, path);
if (existsSync(path)) {
for (let file of readdirSync(path)) {
const filePath = resolve(path, file);
const fileRelative = relative ? posix.join(relative, file) : file;
const stats = statSync(filePath);
if (stats.isFile()) {
if (extname(file) === ".grammar") {
const { options, content } = parseTestFile(readFileSync(filePath, "utf8"));
output.push({ basename: file, path: filePath, relative: fileRelative, content, options });
}
}
else if (stats.isDirectory()) {
collectFilesInPath(filePath, fileRelative, output);
}
}
}
}
示例7: readdirRemote
/**
* Gets the list of files in the remote directory recursively.
*
* @param sftp
* The SFTP client.
* @param remotePath
* The remote directory.
*
* @returns
* A Promise that resolved with the list of remote files.
*/
async function readdirRemote(sftp: SftpClient, remotePath: string): Promise<string[]> {
const files: string[] = []
const remoteFiles = await sftp.list(remotePath)
for (const remoteFile of remoteFiles) {
const remoteFilePath = path.posix.join(remotePath, remoteFile.name)
switch (remoteFile.type) {
case '-':
files.push(remoteFilePath)
break
case 'd':
files.push(...await readdirRemote(sftp, remoteFilePath))
break
}
}
return files
}
示例8: resolve
resolve(url: string): string {
let urlObject = parseUrl(url);
let pathname = pathlib.normalize(decodeURIComponent(urlObject.pathname));
if (!this._isValid(urlObject, pathname)) {
throw new Error(`Invalid URL ${url}`);
}
// If the path points to a sibling directory, resolve it to the
// component directory
if (pathname.startsWith('../')) {
pathname = pathlib.join(this.componentDir,pathname.substring(3));
}
// make all paths relative to the root directory
if (pathlib.isAbsolute(pathname)) {
pathname = pathname.substring(1);
}
return pathname;
}
示例9: createDefaultSnapshotResolver
function createDefaultSnapshotResolver(): SnapshotResolver {
return {
resolveSnapshotPath: (testPath: Config.Path) =>
path.join(
path.join(path.dirname(testPath), '__snapshots__'),
path.basename(testPath) + DOT_EXTENSION,
),
resolveTestPath: (snapshotPath: Config.Path) =>
path.resolve(
path.dirname(snapshotPath),
'..',
path.basename(snapshotPath, DOT_EXTENSION),
),
testPathForConsistencyCheck: path.posix.join(
'consistency_check',
'__tests__',
'example.test.js',
),
};
}
示例10: main
async function main() {
await BluebirdPromise.all([
deleteOldElectronVersion(),
downloadAllRequiredElectronVersions(),
outputFile(path.join(testPackageDir, "package.json"), `{
"private": true,
"version": "1.0.0",
"name": "test",
"dependencies": {
"electron-builder": "file:${path.posix.join(__dirname.replace(/\\/g, "/"), "..", "..")}"
}
}`)
.then(() => copyDependencies())
])
// install from cache - all dependencies are already installed before run test
// https://github.com/npm/npm/issues/2568
await exec("npm", ["install", "--cache-min", "999999999", "--production", rootDir])
// prune stale packages
await exec("npm", ["prune", "--production"])
await runTests()
}