本文整理汇总了TypeScript中Process.cwd函数的典型用法代码示例。如果您正苦于以下问题:TypeScript cwd函数的具体用法?TypeScript cwd怎么用?TypeScript cwd使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cwd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: webpack
gulp.task('task:webpack_test:pack', done => {
console.log(process.cwd());
webpack({
context: `${process.cwd()}/src/test/webpack`,
entry: './index.js',
output: {
path: `${process.cwd()}/tmp/es5/src/test/webpack`,
filename: 'index.js'
},
plugins: [
new AngularServiceWorkerPlugin()
]
}, () => done())
});
示例2: catch
const parsePreboot = (json: string): PrebootConfiguration | boolean => {
let options: PrebootConfiguration;
if (json.trim().startsWith('{')) {
try {
options = fromJson<PrebootConfiguration>(json);
}
catch (exception) {
throw new ConfigurationException('Preboot configuration: invalid JSON document', exception);
}
}
else if (json.length > 0) {
const file = absoluteFile(cwd(), json);
if (file.exists() === false || file.type() !== FileType.File) {
throw new ConfigurationException(`Preboot configuration file does not exist or is not a file: ${file.toString()}`);
}
options = fromJson<PrebootConfiguration>(file.content());
}
else {
return true;
}
const validation = validatePrebootOptionsAgainstSchema(options);
if (validation.errors.length > 0) {
throw new ConfigurationException(`Preboot configuration ${json} is invalid: ${validation.toString()}`)
}
return options;
}
示例3: test_path
export function test_path() {
console.log('\n---- test_path');
console.log(`process.cwd = ${process.cwd()}`);
console.log(`__filename is the module path = ${__filename}`);
console.log(`__dirname is the module containing dir = ${__dirname}`);
}
示例4: webpack
gulp.task('task:webpack_test:pack', done => {
webpack({
context: `${process.cwd()}/src/test/webpack`,
entry: './index.js',
output: {
path: `${process.cwd()}/tmp/es5/src/test/webpack`,
filename: 'index.js'
},
plugins: [
new CopyWebpackPlugin([
{from: 'other.js'},
{from: 'ignored.js'},
{from: 'ngsw-manifest.json'},
]),
new AngularServiceWorkerPlugin({baseHref: '/test'}),
]
}, () => done())
});
示例5: cwd
export const diagnosticsToException = (diagnostics: Array<Diagnostic>): string => {
const host: FormatDiagnosticsHost = {
getCurrentDirectory: (): string => cwd(),
getCanonicalFileName: (filename: string): string => filename,
getNewLine: (): string => EOL,
};
return `Your application failed to compile (to resolve, run tsc from ${cwd()} and resolve these errors: ${formatDiagnostics(diagnostics, host)})`;
};
示例6: join
const renderOptions = (options): OutputOptions => {
let outputString = options['output'];
if (/^(\\|\/)/.test(outputString) === false) {
outputString = join(cwd(), outputString);
}
const output = pathFromString(outputString);
return {filename, output, inlineStylesheets, inlineVectorGraphics};
};
示例7: lintFile
function lintFile(filePath: string) {
const filePathList = [resolve(cwd(), filePath)];
const engine = new TextLintEngine({
rules: ["no-todo", "no-exclamation-question-mark"],
formatterName: "pretty-error",
color: false
});
return engine.executeOnFiles(filePathList).then(function (results: TextlintResult[]) {
if (engine.isErrorResults(results)) {
console.log(engine.formatResults(results));
} else {
console.log("All Passed!");
}
});
}
示例8: it
it('should spawn a Python process even if scriptPath option is not specified', function (done) {
let originalDirectory = cwd()
PythonShell.defaultOptions = {};
chdir(join(__dirname, "python"));
let pyshell = new PythonShell('exit-code.py');
pyshell.command.should.eql(['exit-code.py']);
pyshell.terminated.should.be.false;
pyshell.end(function (err) {
if (err) return done(err);
pyshell.terminated.should.be.true;
done();
});
//reset values to intial status
PythonShell.defaultOptions = {
scriptPath: pythonFolder
};
chdir(originalDirectory)
});
示例9: function
grunt.registerTask('_link', '', function (this: ITask) {
const done = this.async();
const packagePath = pkgDir.sync(process.cwd());
const targetPath = grunt.config('distDirectory');
fs.symlink(
path.join(packagePath, 'node_modules'),
path.join(targetPath, 'node_modules'),
'junction',
() => {}
);
fs.symlink(
path.join(packagePath, 'package.json'),
path.join(targetPath, 'package.json'),
'file',
() => {}
);
execa.shell('npm link', { cwd: targetPath })
.then((result: any) => grunt.log.ok(result.stdout))
.then(done);
});
示例10: test_fs
export function test_fs() {
// 1
console.log('\n---- test_path');
let p = path.normalize(path.join(process.cwd(), 'data/myfile.txt'))
console.log(`fs.open('${p}', 'w')`);
fs.open(p, 'w', (err: any, fd: any) => {
// 2
if (err) {
console.error('error in fs.open()');
throw err;
}
console.log('fs.open() done');
console.log(`fs.write(fd, 'Hello Node.js')`);
fs.write(fd, 'Hello Node.js', (err: any, written: any, string: any) => {
// 3
if (err) {
console.error('error in fs.write()');
throw err;
}
console.log('fs.write() done');
});
});
}
示例11: createDefault
/**
* @internal
*/
public static createDefault(options: EnvOptions): Env {
return new Env(process.cwd(), options);
}
示例12: SendRequest
function SendRequest<P, R, E, RO>(
type: lsp.RequestType<P, R, E, RO>,
params: P,
token?: lsp.CancellationToken
): Thenable<R> {
return connection.sendRequest(type, params, token)
}
function SendNotification<P, RO>(type: lsp.NotificationType<P, RO>): (params: P) => void {
return params => connection.sendNotification(type, params)
}
SendRequest(lsp.InitializeRequest.type, {
processId: process.pid,
rootUri: 'file://' + process.cwd(),
capabilities: {},
trace: 'verbose',
}).then((x: lsp.InitializeResult) => {
console.log('initialized:', x)
const comp = x.capabilities.completionProvider
if (comp) {
const chars = (comp.triggerCharacters || []).join('')
kak.msg(`
hook -group lsp global InsertChar [${chars}] %{exec '<a-;>: lsp-complete<ret>'}
`)
}
const sig = x.capabilities.signatureHelpProvider
if (sig) {
const chars = (sig.triggerCharacters || []).join('')
kak.msg(`
示例13: selector
const parseCommandLine = () => {
const options = commander
.version(version)
.description(chalk.green('Prerender Angular applications'))
.option('-e, --environment <environment>', 'Environment selector (dev, prod) (if not specified, will automatically choose based on --debug')
.option('-d, --debug', 'Enable debugging (stack traces and so forth)', false)
.option('-p, --project <path>', 'Path to tsconfig.json file or project root (if tsconfig.json lives in the root)', cwd())
.option('-w, --webpack <config>', 'Optional path to webpack configuration file')
.option('-t, --template <path>', 'HTML template document', 'dist/index.html')
.option('-f, --filename <path>', 'Change the name of the HTML files that are produced', filename)
.option('-m, --module <path>', 'Path to root application module TypeScript file')
.option('-s, --symbol <identifier>', 'Class name of application root module')
.option('-o, --output <path>', 'Output path to write rendered HTML documents to', 'dist')
.option('-a, --application <applicationID>', 'Optional application ID if your CLI configuration contains multiple apps')
.option('-P, --preboot [boolean | json-file | json-text]', 'Enable or disable preboot with optional configuration file or JSON text (otherwise automatically find the root element and use defaults)')
.option('-R, --pessimistic [boolean]', 'Ignore routes that fail to render (just emit warnings, do not fail the whole run)')
.option('-i, --inline [boolean]', 'Inline of resources referenced in links')
.option('-S, --inline-svg [boolean]', 'Inline SVG <use xlink:href> instances (to resolve issues with absolute URI SVG identifiers eg http://localhost/#foo')
.option('-I, --ipc', 'Send rendered documents to parent process through IPC instead of writing them to disk', false)
.option('-b, --blacklist [boolean]', 'Blacklist all routes by default such that all routes which should be rendered must be specially marked with "server: true" in the route definition', false)
options.on('preboot',
value => enablePreboot = value == null ? true : value);
options.on('inline',
value => inlineStylesheets = value == null ? true : value);
options.on('inline-svg',
value => inlineVectorGraphics = value == null ? true : value);
options.on('blacklist',
value => blacklist = value == null ? true : value);
options.on('pessimistic',
value => pessimistic = value == null ? true : value);
options.on('filename', value => filename = value);
return options.parse(process.argv);
};
示例14: resolve
/**
* Configuration module.
* @module config
* @private
*/
import { resolve } from "path";
import * as process from "process";
export interface Config {
mockService: {
host: string;
port: number;
};
logging: boolean;
}
const PACT_CONFIG_FILE = resolve(process.cwd(), "config", "pact.config.js");
const DEFAULT_PACT_CONFIG: Config = {
logging: false,
mockService: {
host: "127.0.0.1",
port: 1234,
},
};
let config: Config;
try {
// tslint:disable:no-var-requires
config = require(PACT_CONFIG_FILE);
} catch (e) {
config = DEFAULT_PACT_CONFIG;
示例15: catch
}
}
const readMeMulti = cm.createNode(
"document",
cm.createNode(
"heading",
cm.createText("Multi-API support for AutoRest v3 generators")
),
cm.createNode(
"block_quote",
cm.createNode(
"paragraph",
cm.createText("see https://aka.ms/autorest")
)
),
cm.createCodeBlock(
"yaml $(enable-multi-api)",
yaml.dump({ "input-file": it.toArray(set) }, { lineWidth: 1000 })
)
)
const x = cm.markDownExToString({ markDown: readMeMulti })
fs.writeFile(path.join(f.dir, "readme.enable-multi-api.md"), x)
}
}
} catch (e) {
console.error(e)
}
}
main(path.join(process.cwd(), "specification"))