本文整理汇总了TypeScript中path.posix类的典型用法代码示例。如果您正苦于以下问题:TypeScript posix类的具体用法?TypeScript posix怎么用?TypeScript posix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了posix类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
export default function() {
// These testcases are specific to one uncommon behaviour in path module. Few
// of the functions in path module, treat '' strings as current working
// directory. This test makes sure that the behaviour is intact between commits.
// See: https://github.com/nodejs/node/pull/2106
var pwd = process.cwd();
// join will internally ignore all the zero-length strings and it will return
// '.' if the joined string is a zero-length string.
assert.equal(path.posix.join(''), '.');
assert.equal(path.posix.join('', ''), '.');
assert.equal(path.join(pwd), pwd);
assert.equal(path.join(pwd, ''), pwd);
// normalize will return '.' if the input is a zero-length string
assert.equal(path.posix.normalize(''), '.');
assert.equal(path.normalize(pwd), pwd);
// Since '' is not a valid path in any of the common environments, return false
assert.equal(path.posix.isAbsolute(''), false);
// resolve, internally ignores all the zero-length strings and returns the
// current working directory
assert.equal(path.resolve(''), pwd);
assert.equal(path.resolve('', ''), pwd);
// relative, internally calls resolve. So, '' is actually the current directory
assert.equal(path.relative('', pwd), '');
assert.equal(path.relative(pwd, ''), '');
assert.equal(path.relative(pwd, pwd), '');
};
示例2: constructor
private constructor(
relativeFlatIndexPath: string, readonly entryPoint: string,
readonly moduleName: string|null) {
this.flatIndexPath = path.posix.join(path.posix.dirname(entryPoint), relativeFlatIndexPath)
.replace(/\.js$/, '') +
'.ts';
}
示例3:
.map(match => {
const relativePath = path.posix.relative(slashedDirname, match);
return path.posix.dirname(match) === slashedDirname
? `./${relativePath}`
: relativePath;
})
示例4:
return service.resolveFile(uri.file(path.join(testDir, 'index.html'))).then(source => {
const targetParent = uri.file(path.dirname(source.resource.fsPath));
const target = targetParent.with({ path: path.posix.join(targetParent.path, path.posix.basename(source.resource.path)) });
return service.copyFile(source.resource, target, true).then(copied => {
assert.equal(copied.size, source.size);
});
});
示例5: webcomponentsLiteToBundle
/**
* Checks if a path points to webcomponents-lite.js and will change it to
* webcomponents-bundle.js if it does.
*
* @param filePath path to transform.
*/
private webcomponentsLiteToBundle(filePath: string) {
const pathObject = path.posix.parse(filePath);
if (pathObject.base === 'webcomponents-lite.js') {
pathObject.base = 'webcomponents-bundle.js';
}
return path.posix.format(pathObject);
}
示例6: pathFromUrl
export function pathFromUrl(
root: LocalFsPath,
// TODO(usergenic): PackageRelativeUrl are not *necessarily* always just a
// relative path from root. Maybe subclass as PackageRelativeUrlPath or
// something if this function doesn't disappear after
// https://github.com/Polymer/polymer-build/issues/324 is addressed.
url: PackageRelativeUrl): LocalFsPath {
return path.normalize(decodeURIComponent(path.posix.join(
posixifyPath(root), path.posix.join('/', url)))) as LocalFsPath;
}
示例7: toDepNameAndPath
toDepNameAndPath(relativePath: string): { depName: string; path: string; } {
let depName = path.join(path.dirname(this._current.depName), relativePath);
let depPath = path.join(path.dirname(this._current.path), relativePath);
if (path.posix) {
// (windows) for git cli
// path.posix are exists after node v0.12
depName = path.posix.join(path.dirname(this._current.depName), relativePath);
depPath = path.posix.join(path.dirname(this._current.path), relativePath);
}
return {
depName: depName,
path: depPath,
};
}
示例8: it
it('should list lazy routes recursively', () => {
writeSomeRoutes();
const {program, host, options} =
createProgram(['src/main.ts', 'src/child.ts', 'src/child2.ts']);
const routes = NgTools_InternalApi_NG_2.listLazyRoutes({
program,
host,
angularCompilerOptions: options,
entryModule: 'src/main#MainModule',
});
expect(routes).toEqual({
'./child#ChildModule': path.posix.join(testSupport.basePath, 'src/child.ts'),
'./child2#ChildModule2': path.posix.join(testSupport.basePath, 'src/child2.ts'),
});
});
示例9: Buffer
return this._getBundles().then((bundles) => {
let sharedDepsBundle = (this.shell)
? this.urlFromPath(this.shell)
: this.sharedBundleUrl;
let sharedDeps = bundles.get(sharedDepsBundle) || [];
let promises = [];
if (this.shell) {
let shellFile = this.analyzer.getFile(this.shell);
console.assert(shellFile != null);
let newShellContent = this._addSharedImportsToShell(bundles);
shellFile.contents = new Buffer(newShellContent);
}
for (let fragment of this.allFragments) {
let fragmentUrl = this.urlFromPath(fragment);
let addedImports = (fragment === this.shell && this.shell)
? []
: [path.relative(path.dirname(fragmentUrl), sharedDepsBundle)];
let excludes = (fragment === this.shell && this.shell)
? []
: sharedDeps.concat(sharedDepsBundle);
promises.push(new Promise((resolve, reject) => {
let vulcanize = new Vulcanize({
abspath: null,
fsResolver: this.analyzer.resolver,
addedImports: addedImports,
stripExcludes: excludes,
inlineScripts: true,
inlineCss: true,
inputUrl: fragmentUrl,
});
vulcanize.process(null, (err, doc) => {
if (err) {
reject(err);
} else {
resolve({
url: fragment,
contents: doc,
});
}
});
}));
}
// vulcanize the shared bundle
if (!this.shell && sharedDeps && sharedDeps.length !== 0) {
logger.info(`generating shared bundle`);
promises.push(this._generateSharedBundle(sharedDeps));
}
return Promise.all(promises).then((bundles) => {
// convert {url,contents}[] into a Map
let contentsMap = new Map();
for (let bundle of bundles) {
contentsMap.set(bundle.url, bundle.contents);
}
return contentsMap;
});
});