当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript path-exists.sync函数代码示例

本文整理汇总了TypeScript中path-exists.sync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sync函数的具体用法?TypeScript sync怎么用?TypeScript sync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sync函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: hasJSConfig

export function hasJSConfig(): boolean {
    if (!workspace || !workspace.rootPath) {
        return false;
    }

    return pathExists.sync(path.join(workspace.rootPath, "jsconfig.json"));
}
开发者ID:ChrisBriggsy,项目名称:vsc-ember-cli,代码行数:7,代码来源:file-ops.ts

示例2: Promise

    return new Promise((resolve, reject) => {
      let source: string;
      let javaHome: string = process.env.JDK_HOME;
      if (javaHome) {
        source = 'The JDK_HOME environment variable';
      } else {
        javaHome = process.env.JAVA_HOME;
        source = 'The JAVA_HOME environment variable';
      }

      if (javaHome) {
        javaHome = expandHomeDir(javaHome);
        if (!pathExists.sync(javaHome)) {
          reject(source + ' points to a missing folder');
        }
        return resolve(javaHome);
      }

      // No settings, let's try to detect as last resort.
      findJavaHome((err, home) => {
        if (err) {
          reject('Java runtime could not be located');
        } else {
          resolve(home);
        }
      });
    });
开发者ID:dragos,项目名称:dragos-vscode-scala,代码行数:27,代码来源:requirements.ts

示例3: appendJSConfig

export function appendJSConfig(data): boolean {
    if (!workspace || !workspace.rootPath) {
        return false;
    }

    let jscPath = path.join(workspace.rootPath, "jsconfig.json");
    let newJsc;
    let mergedJsc;
    let currentJsc;

    // Check first if a jsconfig.json exists
    if (pathExists.sync(jscPath)) {
        // Merge
        try {
            currentJsc = JSON.parse(fs.readFileSync(jscPath, "utf8"));
            mergedJsc = merge(currentJsc, data);
        } catch (e) {
            console.log(e);
        }
    }

    // Write new config
    try {
        newJsc = mergedJsc || jsConfig;
        fs.writeFileSync(jscPath, JSON.stringify(newJsc), "utf8");
    } catch (e) {
        return false;
    }
}
开发者ID:ChrisBriggsy,项目名称:vsc-ember-cli,代码行数:29,代码来源:file-ops.ts

示例4: hasFile

export function hasFile(file: string): boolean {
    if (!workspace || !workspace.rootPath) {
        return false;
    }

    return pathExists.sync(path.join(workspace.rootPath, file));
}
开发者ID:Georotzen,项目名称:vsc-ember-cli,代码行数:7,代码来源:file-ops.ts

示例5: writeSetting

export function writeSetting(data) {
    let currentConfig, mergedConfig, newConfig;
    // Check first if a jsconfig.json exists
    if (pathExists.sync(configPath)) {
        // Merge
        try {
            currentConfig = JSON.parse(fs.readFileSync(configPath, "utf8"));
            mergedConfig = merge(currentConfig, data);
        } catch (e) {
            console.log(e);
        }
    }

    // Write new config
    try {
        newConfig = mergedConfig || data;
        fs.writeFileSync(configPath, JSON.stringify(newConfig), "utf8");
        return true;
    } catch (e) {
        return false;
    }
}
开发者ID:Georotzen,项目名称:vsc-ember-cli,代码行数:22,代码来源:config.ts

示例6: appendVSCIgnore

export function appendVSCIgnore(ignoreItems: Array<string>): Boolean {
    if (!ignoreItems || ignoreItems.length === 0 || !workspace || !workspace.rootPath) {
        return false;
    }

    let vsciPath = path.join(workspace.rootPath, ".vscodeignore");
    let eol = EOL || (process.platform === "win32" ? "\r\n" : "\n");

    // Let"s first see if the file already exists - and if so,
    // which items we have to fill in
    if (pathExists.sync(vsciPath)) {
        let vsciBuffer = fs.readFileSync(vsciPath);
        let    vsciContent = vsciBuffer.toString().split(/\r?\n/);

        // If there"s anything in that file, we"ll need to add a newline
        if (vsciContent.length > 0) {
            ignoreItems.unshift("");
        }
        // Compare items to ignore and the current .vscodeignore items
        for (let i = 0; i < vsciContent.length; i++) {
            for (let ii = 0; ii < ignoreItems.length; ii++) {
                if (vsciContent[i] === ignoreItems[ii]) {
                    ignoreItems.splice(ii, 1);
                }
            }
        }
    }

    // Now, let"s append the .vscodeignore
    let ignoreContent = ignoreItems.join(eol);

    try {
        fs.appendFileSync(vsciPath, ignoreContent, "utf8");
        return true;
    } catch (e) {
        return false;
    }
}
开发者ID:ChrisBriggsy,项目名称:vsc-ember-cli,代码行数:38,代码来源:file-ops.ts

示例7: Date



let ioSocket: any;



const options: Idefaults = {
    port: 6767,
    secret: new Date().getTime() + "xxx",
    password: 'admindocker'
}




if (pathExists.sync("./conf.json")) merge(options, require("./conf.json"))


app.all("/*", function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");

    next();
});

// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));

// parse application/json
app.use(bodyParser.json());

app.use(cors());
开发者ID:dottgonzo,项目名称:express-docker,代码行数:29,代码来源:index.ts


注:本文中的path-exists.sync函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。