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


TypeScript shelljs.chmod函数代码示例

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


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

示例1: makeDistributedCLIExecutable

function makeDistributedCLIExecutable() {
    const cli = path.join(OUTDIR, "cli", "index.js");
    mapFile(cli, cli, content => {
        if (_.startsWith(content, scriptPrefix)) return content;
        return scriptPrefix + content;
    });
    shell.chmod("+x", cli);
}
开发者ID:nrkn,项目名称:quicktype,代码行数:8,代码来源:build.ts

示例2: constructor

    constructor(level: cm.DiagnosticLevel, fullPath: string, fileName: string) {
        this.level = level;
        shell.mkdir('-p', fullPath);
        shell.chmod(775, fullPath);

        // TODO: handle failure cases.  It throws - Error: ENOENT, open '/nopath/somefile.log'
        //       we probably shouldn't handle - fail to start with good error - better than silence ...
        this._fd = fs.openSync(path.join(fullPath, fileName), 'a');  // append, create if not exist
    }
开发者ID:itsananderson,项目名称:vso-agent,代码行数:9,代码来源:diagnostics.ts

示例3: removeDir

 protected removeDir(dir: string) {
   try {
     if (shell.test('-d', dir)) {
       shell.chmod('-R', 'a+w', dir);
       shell.rm('-rf', dir);
     }
   } catch (err) {
     console.error(`ERROR: Unable to remove '${dir}' due to:`, err);
   }
 }
开发者ID:Polatouche,项目名称:angular,代码行数:10,代码来源:build-cleaner.ts

示例4: reject

      cp.exec(cmd, (err, _stdout, stderr) => {
        if (err) {
          return reject(err);
        }

        if (stderr) {
          console.warn(stderr);
        }

        try {
          shell.chmod('-R', 'a-w', outputDir);
          shell.rm('-f', inputFile);
          resolve();
        } catch (err) {
          reject(err);
        }
      });
开发者ID:Polatouche,项目名称:angular,代码行数:17,代码来源:build-creator.ts

示例5: copyFile

  function copyFile(file: string, baseDir: string, relative = '.') {
    const dir = path.join(baseDir, relative);
    shx.mkdir('-p', dir);
    shx.cp(file, dir);
    // Double-underscore is used to escape forward slash in FESM filenames.
    // See ng_package.bzl:
    //   fesm_output_filename = entry_point.replace("/", "__")
    // We need to unescape these.
    if (file.indexOf('__') >= 0) {
      const outputPath = path.join(dir, ...path.basename(file).split('__'));
      shx.mkdir('-p', path.dirname(outputPath));
      shx.mv(path.join(dir, path.basename(file)), outputPath);

      // if we are renaming the .js file, we'll also need to update the sourceMappingURL in the file
      if (file.endsWith('.js')) {
        shx.chmod('+w', outputPath);
        shx.sed('-i', `${path.basename(file)}.map`, `${path.basename(outputPath)}.map`, outputPath);
      }
    }
  }
开发者ID:Cammisuli,项目名称:angular,代码行数:20,代码来源:packager.ts

示例6: RegExp

		tl.warning("No files found");
	} else {
		for (var i = 0; i < filesToReplace.length; i++) {
            var file = filesToReplace[i];
            console.info(`Changing version in ${file}`);
            
            var contents = fs.readFileSync(file, 'utf8').toString();
            var checkMatches = new RegExp(replaceRegex).exec(contents);
            if (!checkMatches || checkMatches.length === 0) {
                if (failIfNoMatchFound) {
                    tl.error(`No matches for regex [${replaceRegex}] found in file ${file}`);
                    process.exit(1);
                } else {
                    tl.warning(`No matches for regex [${replaceRegex}] found in file ${file}`);
                }
            } else {
                console.info(`${checkMatches.length} matches for regex [${replaceRegex}] found in file ${file}`);
                
                // make the file writable
                sh.chmod(666, file);
                // replace all occurrences by adding g to the pattern
                sh.sed("-i", new RegExp(replaceRegex, "g"), replacePrefix + versionNum, file);
            }
        }
		console.info(`Processed ${filesToReplace.length} files`);
	}
} else {
	tl.warning(`Could not extract a version from [${buildNumber}] using pattern [${buildRegex}]`);
}

tl.debug("Leaving Version Assemblies step");
开发者ID:dixu99,项目名称:cols-agent-tasks,代码行数:31,代码来源:versionAssemblies.ts

示例7: run

async function run() {
    try {
        tl.debug("Starting Tokenizer task");

        // get the task vars
        var sourcePath = tl.getPathInput("sourcePath");
        if (!sourcePath || sourcePath.length === 0) {
            sourcePath = tl.getVariable("Build.SourcesDirectory");
        }
        // clear leading and trailing quotes for paths with spaces
        sourcePath = sourcePath.replace(/"/g, "");

        // remove trailing slash
        if (sourcePath.endsWith("\\") || sourcePath.endsWith("/")) {
            tl.debug("Trimming separator off sourcePath");
            sourcePath = sourcePath.substr(0, sourcePath.length - 1);
        }

        tl.checkPath(sourcePath, "sourcePath");

        let filePattern = tl.getInput("filePattern", true);
        let tokenizeType = tl.getInput("tokenizeType", true);
        let includes = tl.getInput("includes", false);
        let excludes = tl.getInput("excludes", false);
        if (!includes) {
            includes = '';
        }
        if (!excludes) {
            excludes = '';
        }

        tl.debug(`sourcePath: [${sourcePath}]`);
        tl.debug(`filePattern: [${filePattern}]`);
        tl.debug(`tokenizeType: [${tokenizeType}]`);
        tl.debug(`includes: [${includes}]`);
        tl.debug(`excludes: [${excludes}]`);

        // only one or the other can be specified
        if (includes && includes.length > 0 && excludes && excludes.length > 0) {
            throw `You cannot specify includes and excludes - please specify one or the other`;
        }

        if (!filePattern || filePattern.length === 0) {
            filePattern = "*.*";
        }
        tl.debug(`Using [${filePattern}] as filePattern`);

        // create a glob removing any spurious quotes
        if (os.platform() !== "win32") {
            // replace \ with /
            filePattern = filePattern.replace(/\\/g, "/");
        }

        // get the files
        let files = tl.findMatch(sourcePath, filePattern);
        if (!files || files.length === 0) {
            let msg = `Could not find files with glob [${filePattern}].`;
            if (os.platform() !== "win32") {
                tl.warning("No files found for pattern. Non-windows file systems are case sensitvive, so check the case of your path and file patterns.");
            }
            tl.setResult(tl.TaskResult.Failed, msg);
        }

        // comma-split the include and excludes
        let includeSet: Set<string>, excludeSet: Set<string>;
        if (includes && includes.length > 0) {
            includeSet = new Set(includes.split(','));
            tl.debug(`Includeset has ${includeSet.size} elements`);
        }
        if (excludes && excludes.length > 0) {
            excludeSet = new Set(excludes.split(','));
            tl.debug(`Excludeset has ${excludeSet.size} elements`);
        }

        for (var i = 0; i < files.length; i++) {
            let file = files[i];
            console.info(`Starting tokenization in [${file}]`);

            let contents = fs.readFileSync(file).toString();
            // remove BOM if present
            contents = contents.replace(String.fromCharCode(65279), '');
            let json = JSON.parse(contents);

            // find the include properties recursively
            replaceProps(json, '', includeSet, excludeSet);

            tl.debug("Writing new values to file...");
            // make the file writable
            sh.chmod(666, file);
            fs.writeFileSync(file, JSON.stringify(json, null, 2));
        }

    }
    catch (err) {
        let msg = err;
        if (err.message) {
            msg = err.message;
        }
        tl.setResult(tl.TaskResult.Failed, msg);
    }
//.........这里部分代码省略.........
开发者ID:xiangyan99,项目名称:cols-agent-tasks,代码行数:101,代码来源:tokenizer.ts

示例8:

	console.log('updating agent.  removing old code.')
	shell.rm('-rf', agentTarget);
}

var modsTarget = path.join(targetDir, 'node_modules');
if (shell.test('-d', modsTarget)) {
	console.log('updating node modules.  removing old modules.')
	shell.rm('-rf', modsTarget);
}

var pkgTarget = path.join(targetDir, 'package.json');
if (shell.test('-f', pkgTarget)) {
	console.log('updating agent.  removing old package.json')
	shell.rm('-f', pkgTarget);
}

// copy new bits
console.log('Copying: ', agentDir, targetDir);
shell.cp('-R', agentDir, targetDir);

var modsDir = path.join(installDir, 'node_modules');
var targetAgent = path.join(targetDir, 'agent');
console.log('Copying: ', modsDir, targetDir);
shell.cp('-R', modsDir, targetDir);
shell.cp(path.join(installDir, 'package.json'), targetDir);

console.log('making scripts executable')
shell.chmod('u+x', path.join(targetAgent, 'svc.sh'));
shell.chmod('u+x', path.join(targetAgent, 'plugins/build/lib/askpass.js'));

console.log('Done.');
开发者ID:itsananderson,项目名称:vso-agent,代码行数:31,代码来源:installer.ts

示例9: run

async function run() {
    try {
        tl.debug("Starting Replace Tokens task");

        // get the task vars
        var sourcePath = tl.getPathInput("sourcePath");
        if (!sourcePath || sourcePath.length === 0) {
            sourcePath = tl.getVariable("Build.SourcesDirectory");
        }

        // clear leading and trailing quotes for paths with spaces
        sourcePath = sourcePath.replace(/"/g, "");

        // remove trailing slash
        if (sourcePath.endsWith("\\") || sourcePath.endsWith("/")) {
            tl.debug("Trimming separator off sourcePath");
            sourcePath = sourcePath.substr(0, sourcePath.length - 1);
        }
        
        tl.checkPath(sourcePath, "sourcePath");

        var filePattern = tl.getInput("filePattern", true);
        var tokenRegex = tl.getInput("tokenRegex", true);
        var secretTokenInput = tl.getInput("secretTokens", false);

        // store the tokens and values if there is any secret token input 
        var secretTokens: {[id: string]: string} = {};
        if (secretTokenInput != null && typeof secretTokenInput !== 'undefined') {
            var inputArray : string[] = secretTokenInput.split(";");
            for (var token of inputArray) {
                if (token.indexOf(":") > -1) {  
                    var valArray : string[] = token.split(":");
                    if (valArray.length == 2) {
                        var key = valArray[0].trim().toLowerCase();
                        secretTokens[key] = valArray[1].trim();
                        console.log(`Secret token input found [${key}]`); 
                    }
                }
            }
            tl.debug(`secretTokens: found [${Object.keys(secretTokens).length}] tokens`);    
        }

        tl.debug(`sourcePath: [${sourcePath}]`);
        tl.debug(`filePattern: [${filePattern}]`);
        tl.debug(`tokenRegex: [${tokenRegex}]`);

        if (!filePattern || filePattern.length === 0){
            filePattern = "*.*";
        }
        tl.debug(`Using [${filePattern}] as filePattern`);

        // create a glob removing any spurious quotes
        if (os.platform() !== "win32") {
            // replace \ with /
            filePattern = filePattern.replace(/\\/g, "/");
        }

        var files = tl.findMatch(sourcePath, filePattern);
        if (!files || files.length === 0) {
            var msg = `Could not find files with glob [${filePattern}].`;
            if (os.platform() !== "win32") {
                tl.warning("No files found for pattern. Non-windows file systems are case sensitvive, so check the case of your path and file patterns.");
            }
            tl.setResult(tl.TaskResult.Failed, msg);
        }
        for (var i = 0; i < files.length; i++) {
            var file = files[i];
            console.info(`Starting regex replacement in [${file}]`);
            
            var contents = fs.readFileSync(file).toString();
            var reg = new RegExp(tokenRegex, "g");
                    
            // loop through each match
            var match: RegExpExecArray;
            // keep a separate var for the contents so that the regex index doesn't get messed up
            // by replacing items underneath it
            var newContents = contents;
            while((match = reg.exec(contents)) !== null) {
                var vName = match[1];
                if (typeof secretTokens[vName.toLowerCase()] !== 'undefined') {
                    // try find the variable in secret tokens input first
                    newContents = newContents.replace(match[0], secretTokens[vName.toLowerCase()]);
                    console.info(`Replaced token [${vName}] with a secret value`);
                } else {
                    // find the variable value in the environment
                    var vValue = tl.getVariable(vName);
                    if (typeof vValue === 'undefined') {
                        tl.warning(`Token [${vName}] does not have an environment value`);
                    } else {
                        newContents = newContents.replace(match[0], vValue);
                        console.info(`Replaced token [${vName }]`);
                    }           
                }
            }
            tl.debug("Writing new values to file...");
            
            // make the file writable
            sh.chmod(666, file);
            fs.writeFileSync(file, newContents);
        }
//.........这里部分代码省略.........
开发者ID:xiangyan99,项目名称:cols-agent-tasks,代码行数:101,代码来源:replaceTokens.ts

示例10: run


//.........这里部分代码省略.........
        tl.debug(`replacePrefix: ${replacePrefix}`);
        tl.debug(`replacePostfix: ${replacePostfix}`);
        tl.debug(`buildNumber: ${buildNumber}`);

        let buildRegex = customBuildRegex;
        switch (versionFormat) {
            default:
            case "fourParts": buildRegex = "\\d+\\.\\d+\\.\\d+\\.\\d+"; break;
            case "threeParts": buildRegex = "\\d+\\.\\d+\\.\\d+"; break;
            case "custom": buildRegex = customBuildRegex; break;
        }
        let replaceRegex = customReplaceRegex;
        switch (replaceVersionFormat) {
            default:
            case "fourParts": replaceRegex = "\\d+\\.\\d+\\.\\d+\\.\\d+"; break;
            case "threeParts": replaceRegex = "\\d+\.\\d+\\.\\d+"; break;
            case "custom": replaceRegex = customReplaceRegex; break;
        }

        tl.debug(`Using ${buildRegex} as the build regex`);
        tl.debug(`Using ${replaceRegex} as the replacement regex`);

        if (!buildRegexIndex || buildRegexIndex.length === 0){
            buildRegexIndex = "0";
        }
        tl.debug(`Using ${buildRegexIndex} as the build regex group index`);

        let separator = os.platform() === "win32" ? "\\" : "/";

        let versionNum = "";
        let skip = false;
        switch (versionSource) {
            case "variable": {
                versionNum = tl.getVariable(customNumberVariable);
                console.info(`Using ${versionNum} for the custom version number`);
                break;
            }
            default:
            case "buildNumber": {
                let buildRegexObj = new RegExp(buildRegex);
                if (buildRegexObj.test(buildNumber)) {
                    versionNum = buildRegexObj.exec(buildNumber)[buildRegexIndex];
                } else {
                    skip = true;
                    tl.warning(`Could not extract a version from [${buildNumber}] using pattern [${buildRegex}]`);
                }
                break;
            }
        }

        if (!skip) {
            console.info(`Using prefix [${replacePrefix}] and version [${versionNum}] and postfix [${replacePostfix}] in folder [${sourcePath}]`);
            
            if (os.platform() !== "win32") {
                // replace \ with /
                filePattern = filePattern.replace(/\\/g, "/");
            }
            let filesToReplace = tl.findMatch(sourcePath, filePattern);
            
            if (!filesToReplace || filesToReplace.length === 0) {
                tl.warning("No files found");
            } else {
                for (let i = 0; i < filesToReplace.length; i++) {
                    let file = filesToReplace[i];
                    console.info(`Changing version in ${file}`);
                    
                    let contents = fs.readFileSync(file, 'utf8').toString();
                    let checkMatches = new RegExp(replaceRegex).exec(contents);
                    if (!checkMatches || checkMatches.length === 0) {
                        if (failIfNoMatchFound) {
                            tl.setResult(tl.TaskResult.Failed, `No matches for regex [${replaceRegex}] found in file ${file}`);
                            process.exit(1);
                        } else {
                            tl.warning(`No matches for regex [${replaceRegex}] found in file ${file}`);
                        }
                    } else {
                        console.info(`${checkMatches.length} matches for regex [${replaceRegex}] found in file ${file}`);
                        
                        let replaceVal = replacePrefix + versionNum + replacePostfix;
                        let result = contents.replace(new RegExp(replaceRegex, "g"), replaceVal);
                        
                        // make the file writable
                        sh.chmod(666, file);
                        fs.writeFileSync(file, result, { encoding: 'utf8' });
                    }
                }
                console.info(`Processed ${filesToReplace.length} files`);
            }
        }
    }
    catch (err) {
        let msg = err;
        if (err.message) {
            msg = err.message;
        }
        tl.setResult(tl.TaskResult.Failed, msg);
    }

    tl.debug("Leaving Version Assemblies step");
}
开发者ID:xiangyan99,项目名称:cols-agent-tasks,代码行数:101,代码来源:versionAssemblies.ts


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