當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Process.cwd函數代碼示例

本文整理匯總了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())
});
開發者ID:mgechev,項目名稱:mobile-toolkit,代碼行數:14,代碼來源:gulpfile.ts

示例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;
}
開發者ID:sonukapoor,項目名稱:angular-ssr,代碼行數:32,代碼來源:parse.ts

示例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}`);
}
開發者ID:autodefrost,項目名稱:sandbox,代碼行數:7,代碼來源:test_fs.ts

示例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())
});
開發者ID:webmaxru,項目名稱:mobile-toolkit,代碼行數:18,代碼來源:gulpfile.ts

示例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)})`;
};
開發者ID:sonukapoor,項目名稱:angular-ssr,代碼行數:9,代碼來源:diagnostics.ts

示例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};
};
開發者ID:sonukapoor,項目名稱:angular-ssr,代碼行數:11,代碼來源:parse.ts

示例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!");
        }
    });
}
開發者ID:textlint,項目名稱:textlint,代碼行數:17,代碼來源:index.ts

示例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)
        });
開發者ID:extrabacon,項目名稱:python-shell,代碼行數:20,代碼來源:test-python-shell.ts

示例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);
	});
開發者ID:dylans,項目名稱:grunt-dojo2,代碼行數:22,代碼來源:link.ts

示例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');
    });
  });
}
開發者ID:autodefrost,項目名稱:sandbox,代碼行數:23,代碼來源:test_fs.ts

示例11: createDefault

 /**
  * @internal
  */
 public static createDefault(options: EnvOptions): Env {
   return new Env(process.cwd(), options);
 }
開發者ID:Jaaess,項目名稱:kibana,代碼行數:6,代碼來源:env.ts

示例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(`
開發者ID:Franciman,項目名稱:kakoune-languageclient,代碼行數:30,代碼來源:main.ts

示例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);
};
開發者ID:sonukapoor,項目名稱:angular-ssr,代碼行數:40,代碼來源:parse.ts

示例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;
開發者ID:elliottmurray,項目名稱:pact-js,代碼行數:31,代碼來源:config.ts

示例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"))
開發者ID:Nking92,項目名稱:azure-rest-api-specs,代碼行數:30,代碼來源:multiapi.ts


注:本文中的Process.cwd函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。