當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。