小编tom*_*tom的帖子

使用 shell 脚本查找特定文件类型的文件

我需要递归遍历目录中某些文件类型的所有文件。文件类型是一个数组变量,其中包含我们需要处理的文件类型列表。数组值实际上是动态填充的。为了简单起见,我声明了一个静态数组。

 declare -a arr=("pdf" "doc" "txt")
Run Code Online (Sandbox Code Playgroud)

我有以下代码递归列出目录中的所有文件,但我无法弄清楚如何包含数组“arr”以仅取回包含在数组中的那些文件类型。

find $i -type f -print0 | while read -d $'\0' file; do
    echo $file;
    #Process file
done
Run Code Online (Sandbox Code Playgroud)

请帮我修改代码,以便我只能检索指定的文件类型而不是所有文件。

bash shell file find

3
推荐指数
1
解决办法
2418
查看次数

模拟命名出口用于使用Jest进行测试

我有一个Helper.js具有以下几个辅助功能的文件,该文件正在不同的组件中使用。

    export function buildOptions(elem) { 
        var oList=[];   
        for (var i=0; i < field.length; i++) {
            oList.push (
              <option value={options[i]["id"]}>
                  {options[i][elem]}
              </option>
            )
         }    
         return oList;
      }

      export function B(){
           .....
      }
Run Code Online (Sandbox Code Playgroud)

这是一个利用Helper.js文件中定义的功能的组件。我正在为组件编写测试,我想模拟在此调用的外部函数。

    import React from 'react';
    import ReactDOM from 'react-dom';
    import { buildOptions, A} from './Helper.js';

    class DemoComponent extends React.Component {
        constructor(props) {
            super(props);
        }

        add(e, index) {
            ....
        }


        render() {
            var o_list=buildOptions("name");

            return (
               <div>
                  ...
                  <select required className={selectClass}  >
                      {o_list}
                  </select>  
                  ...           
                  <button …
Run Code Online (Sandbox Code Playgroud)

unit-testing mocking jestjs

3
推荐指数
1
解决办法
5887
查看次数

标签 统计

bash ×1

file ×1

find ×1

jestjs ×1

mocking ×1

shell ×1

unit-testing ×1