fs#chmodSync TypeScript Examples

The following examples show how to use fs#chmodSync. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: gcc.test.ts    From setup-cpp with Apache License 2.0 6 votes vote down vote up
describe("setup-gcc", () => {
  let directory: string
  beforeAll(async () => {
    directory = await setupTmpDir("gcc")
  })

  it("should setup gcc", async () => {
    const version = getVersion("gcc", undefined)
    const installInfo = await setupGcc(version, directory, process.arch)

    let gpp = "g++"
    if (process.platform !== "win32") {
      gpp = `g++-${version}`
    }
    await testBin(gpp, ["--version"], installInfo?.binDir)

    expect(process.env.CC?.includes("gcc")).toBeTruthy()
    expect(process.env.CXX?.includes("g++")).toBeTruthy()

    // test compilation
    const file = path.join(__dirname, "main.cpp")
    const main_exe = path.join(__dirname, addBinExtension("main"))
    execa.sync("g++", [file, "-o", main_exe], { cwd: __dirname })
    if (process.platform !== "win32") {
      chmodSync(main_exe, "755")
    }
    execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" })
  })

  afterAll(async () => {
    await cleanupTmpDir("gcc")
  }, 100000)
})
Example #2
Source File: make-cli-executable.ts    From airnode with MIT License 5 votes vote down vote up
// default is 664
chmodSync('packages/airnode-admin/dist/bin/admin.js', addExecuteRightsMode);
Example #3
Source File: make-cli-executable.ts    From airnode with MIT License 5 votes vote down vote up
chmodSync('packages/airnode-deployer/dist/bin/deployer.js', addExecuteRightsMode);
Example #4
Source File: make-cli-executable.ts    From airnode with MIT License 5 votes vote down vote up
chmodSync('packages/airnode-validator/dist/cjs/bin/validator.js', addExecuteRightsMode);
Example #5
Source File: llvm.test.ts    From setup-cpp with Apache License 2.0 4 votes vote down vote up
describe("setup-llvm", () => {
  let directory: string
  beforeAll(async () => {
    directory = await setupTmpDir("llvm")
  })

  it("Finds URL for ubuntu version", async () => {
    expect(
      await getSpecificVersionAndUrl(VERSIONS, "linux", "13.0.0-ubuntu-16.04", (_plantform, version) =>
        getLinuxUrl(version)
      )
    ).toStrictEqual([
      "13.0.0-ubuntu-16.04",
      "https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz",
    ])
    expect(
      await getSpecificVersionAndUrl(VERSIONS, "linux", "13.0.1-ubuntu-18.04", (_plantform, version) =>
        getLinuxUrl(version)
      )
    ).toStrictEqual([
      "13.0.1-ubuntu-18.04",
      "https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz",
    ])
    expect(
      await getSpecificVersionAndUrl(VERSIONS, "linux", "13.0.0-ubuntu-20.04", (_plantform, version) =>
        getLinuxUrl(version)
      )
    ).toStrictEqual([
      "13.0.0-ubuntu-20.04",
      "https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz",
    ])
  })

  it("Finds valid LLVM URLs", async () => {
    await Promise.all(
      [
        // "14.0.1",
        "14.0.0",
        "13.0.0",
        "12.0.0",
        "12",
        "11",
        "11.0.0",
        "10",
        "10.0.0",
        "9.0.0",
        "8",
        "8.0.0",
        "7.0.0",
        "7",
        "6",
        "6.0.0",
        "5",
        "5.0.0",
        "4",
      ].map((version) => testUrl(version))
    )
  })

  it("should setup LLVM", async () => {
    const osVersion = await ubuntuVersion()
    const { binDir } = await setupLLVM(getVersion("llvm", "true", osVersion), directory, process.arch)
    await testBin("clang++", ["--version"], binDir)

    expect(process.env.CC?.includes("clang")).toBeTruthy()
    expect(process.env.CXX?.includes("clang++")).toBeTruthy()

    // test compilation
    const file = path.join(__dirname, "main.cpp")
    const main_exe = path.join(__dirname, addBinExtension("main"))
    execa.sync("clang++", [file, "-o", main_exe], { cwd: __dirname })
    if (process.platform !== "win32") {
      chmodSync(main_exe, "755")
    }
    execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" })
  })

  it("should find llvm in the cache", async () => {
    const osVersion = await ubuntuVersion()
    const { binDir } = await setupLLVM(getVersion("llvm", "true", osVersion), directory, process.arch)
    await testBin("clang++", ["--version"], binDir)

    if (isGitHubCI() && process.platform !== "linux") {
      expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
      // TODO returns the install dir on linux
    }

    expect(process.env.CC?.includes("clang")).toBeTruthy()
    expect(process.env.CXX?.includes("clang++")).toBeTruthy()

    if (isGitHubCI() && process.platform !== "linux") {
      expect(process.env.CC).toMatch("hostedtoolcache")
      expect(process.env.CXX).toMatch("hostedtoolcache")
    }
  })

  it("should setup clang-tidy and clang-format", async () => {
    const osVersion = await ubuntuVersion()
    const { binDir } = await setupClangTools(getVersion("llvm", "true", osVersion), directory, process.arch)
    await testBin("clang-tidy", ["--version"], binDir)
    await testBin("clang-format", ["--version"], binDir)
  })

  afterAll(async () => {
    await cleanupTmpDir("llvm")
  }, 100000)
})