2015-03-21 3 views
1

Я пишу задачу Gulp, которая выполнит запрос curl для загрузки файла в API.Задача gulp child_process.spawn curl error

Вот запрос, который выполняется, как ожидалось из командной строки:

curl \ 
    -F "files[strings.pot][email protected]/path/to/file/i18n/strings.pot" \ 
    -F "json=true" \ 
    https://api.crowdin.com/api/project/xxxxxx/update-file?key=yyyyyy 

Вот задача, которую я написал до сих пор:

var args = []; 
args.push('-F "files[strings.pot][email protected]/path/to/file/i18n/strings.pot"') 
args.push('-F "json=true"'); 
args.push('https://api.crowdin.com/api/project/'+meta.crowdin.projectIdentifier+'/update-file?key='+meta.crowdin.projectKey); 

cp.spawn('curl', args, { stdio: 'inherit' }) 
.on('close', function(){ 
    bundleLogger.end("Crowdin - Did upload POT in"); 
}) 
.on('exit', function(code){ 
    console.log('Exit code: '+code); 
}); 

Это возвращает curl: (26) couldn't open file "/path/to/file/i18n/strings.pot".

Создает ли child_process различные разрешения или $ PATH или что-то, что может вызвать эту ошибку?

ответ

0

Я исправил эту проблему.

Двойные кавычки около "files[strings.pot]..." рассматривались как часть имени файла. Эта работа:

var args = []; 
args.push('-F files[strings.pot][email protected]/path/to/file/i18n/strings.pot'); 
args.push('-F json=true'); 
args.push('https://api.crowdin.com/api/project/'+meta.crowdin.projectIdentifier+'/update-file?key='+meta.crowdin.projectKey); 

cp.spawn('curl', args, { stdio: 'inherit' }) 
.on('close', function(){ 
    bundleLogger.end("Crowdin - Did upload POT in"); 
}) 
.on('exit', function(code){ 
    console.log('Exit code: '+code); 
}); 
Смежные вопросы